I am looking for a way to evaluate string expressions.
I know about SCRIPT control but this control can't do my job.
Basically I wish to calculate functions. Something like this:
Say I have a mathematically function: y = E(x) where E is an expression I don't know at design time. So I need to calculate y by evaluate E at run time. Something like this:
Expand|Select|Wrap|Line Numbers
- Sub Test
- Dim Y as Double, x As Double, E as String
- x = 2
- E = "x + 5"
- Y = Fx(x,E)
- Debug.Print Y 'Should return 7
- E = "3*x+4"
- Y = Fx(x,E)
- Debug.Print Y 'Should return 10
- End Sub
- Private Function Fx(x As Double, Ex As String)
- Y = Value of Ex ??????
- End Function
Can you help me ?
Thank you !