Use function Solver of Excel in VB.NET 2003
I want to use the function Solver, which exists as a tool in Excel, in VB.NET 2003. What i want to do is to build a project in which i can give a desired output in order the program can tell to me what the initial data must be. I had this implemented in Excel using the solver, but i must build a Windows Application doing apart from other things and this jop.
During the search i had done all the weak i didn' t find anything usefull in Studio .Net 2003. If anyone knows sth about that, i would be glad hearing his/hers ideas and suggestions.
Thanks for your time spending on reading my post.
Re Solver Problems in vb.net with excel
Hy there... it took me quite along time, because in the Net you don't find quite something according to this thread.
At first: it is possible to access the Solver from .net via excel.
Maybe one has to create a Temp-excel file to use it just in .net
My Example shows how you can Use the solver with a Macro defined in your Excel file.
at first you need to set the reference to excel in .net:
Click on References, add reference.
Click the .com button and browse to the Microsoft office Folder in which the Excel.exe is located.
Add it. (This also works with some other parts of the office package)
Now you should see EXCEL in your references
Imports Microsoft.Office.Interop 'so you have the opportunity to access excel without writing this stuff NOTE: this imports has nothing to do with references... you CAN use excel without this!
Public Class Form1
Dim oExcelApp As Excel.Application
Dim oExcelWorkbook As Excel.Workbook
Dim oExcelWorksheet As Excel.Worksheet
private sub subExcelSolver
dim tmpStringPath as string = c:\Data\..\tmp.xls
oExcelApp = New Excel.Application
oExcelApp .Visible = True 'if you want to see it FALSE if not
oExcelWorkbook = xlApp.Workbooks.Open(tmpStringPath)
oExcelWorksheet = xlMappe.Worksheets(1)
oExcelApp .Run("Solver.xla!Auto_Open") ' !!!!!!!!!!
dim tmpIntValue as integer = 44 'This is the Value that should be the result
oExcelApp .Run("subVbaExecuteSolver", tmpIntValue , some other parameters maybe changed cells, etc.)
within your Excel file
add a new Module
and place a sub like this
Public Sub subVbaExecuteSolver(ByVal SomeValue As integer, byval other parameters)
SolverOk SetCell:="B2", MaxMinVal:=1, ByChange:="A1","C2"
And now have some fun!
By angela_quests in forum VB Classic
Last Post: 04-13-2007, 04:57 AM
By carzunli in forum Mobile
Last Post: 11-15-2006, 05:13 AM
By Patrick Troughton in forum .NET
Last Post: 02-23-2003, 06:22 PM
By Michael Shutt in forum VB Classic
Last Post: 04-05-2001, 02:25 AM
By Patrick Comeau in forum VB Classic
Last Post: 03-22-2001, 10:50 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL