Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » evaluate a string input by user
Closed Thread
Old 02-12-2004, 06:13 PM   #1 (permalink)
 
Super Techie

Join Date: Dec 2003

Posts: 333

Harold III

Send a message via AIM to Harold III
Default evaluate a string input by user

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?
__________________
I do this for Aiur. NOT YOU.
Harold III is offline  
Old 04-09-2004, 07:05 PM   #2 (permalink)
 
Newb Techie

Join Date: Apr 2004

Posts: 25

nemesis2004

Default

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
nemesis2004 is offline  
Old 04-09-2004, 09:43 PM   #3 (permalink)
FireFox's Avatar
 
Ultra Techie

Join Date: Apr 2004

Posts: 608

FireFox is on a distinguished road

Default

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.
__________________
FireFox is offline  
Old 04-13-2004, 11:57 AM   #4 (permalink)
 
Super Techie

Join Date: Apr 2004

Posts: 316

BlazingWolf

Default

Quote:
x^2+x+2
I'll assume you want X to be what the user inputs?
What does the ^ represent in that problem?
BlazingWolf is offline  
Old 04-13-2004, 01:57 PM   #5 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

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?
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On