-
Well, I'm not that of a experienced programmer, but I use VB to implement some Operations Reserach algorithms.
How can I do the following?
The user types in a textbox/inputbox some function (like 3*x+5). How can I use this function as an input in the following procedure, let's say:
Function integrate(?) as Double
....
integrate=area
End Function
(for example when you want to numerically integrate this function)
Any help greatly appreciated...
Kind regards,
Gertjan
-
Well, I'm not sure I understand your question, but if you are asking how to pass a string from a textbox to a function, then you would do this:
Code:
Option Explicit
'Here is the function
Private Function Integrate(sInput As String) As Double
'Here you would have to place complicated code to parse the string, pulling out
'numbers and operators. Then you would have to actually perform the calculations
'and place the result into the function name
Integrate = dResult
End Function
'Here is where you would call the function using the textbox text
Private Sub Command1_Click()
Text2.Text = Integrate(Text1.Text)
End Sub
As far as I know there is no easy way to take a string containing a formula and convert it so you can use it for a calculation. You might consider using a calculator control, or just use a text box for numeric input and command buttons with the operators on them as captions, like your own custom calculator.
Good luck,
~seaweed