evaluate a string input by user

Status
Not open for further replies.

Harold III

In Runtime
Messages
333
for example, the user input a string of math expression like,
x^2+x+2

how can I convert it to a expression that VB can use to evaluate its value with given x?

and in python it is really easy to do, just use
input(1+1)
and it stores 2 instead of "1+1"
but how to do this in VB?
 
Hmm, I did it once but i've completely forgotten.
I'll try and find the project file and i'll get back to you
 
I don'tk now anything about VB, sorry. I haven't gotten bored enough to learn VB. If you were wondering how to do it in C or C++ then I could help you.
 
I don't really get what you're trying to say, but say you have a textbox (txtX) and the user inputs a value for x.

Dim x as Long
Dim sum as Long

x = Clng(txtX.Text)

sum = x^2 + x +2

Msgbox sum

Is that what you're getting at, or did I miss the point entirely?
 
Status
Not open for further replies.
Back
Top Bottom