|
-
Jun 19th, 2003, 02:58 AM
#1
Thread Starter
Addicted Member
How can turn a string formula into its numeric value?
hi guys
well during the code we can have:
dim a as integer
a=val( Inputbox("Number?"))
x=a^2+3*sin(2*a) 'some formula
but what if i want to ask the user for the formula? for example the user enters the formula in a textbox and i use the formula to get the value of x above. or simply if the user enter's "2*3^2/5" (as a string ) then i can have the answer. is it possiable?
-
Jun 19th, 2003, 03:37 AM
#2
Frenzied Member
I would have thought you just need a routine to look for key characters
e.g examine the string char by char, ASCII 40 to 47 have maths operators I think
-
Jun 19th, 2003, 05:48 AM
#3
Frenzied Member
Or as I have just found out, use the Microsoft Script Control!
http://www.vbforums.com/showthread.p...Script+Control
-
Jun 19th, 2003, 08:23 AM
#4
PowerPoster
Add 'Microsoft Access 8.0 Object Library' to your project's reference and use code like this
myString = "((3+5)*4)-(40/2)-10)"
MsgBox Eval(myString)
-
Jun 19th, 2003, 04:10 PM
#5
Thread Starter
Addicted Member
Originally posted by phinds
Add 'Microsoft Access 8.0 Object Library' to your project's reference and use code like this
myString = "((3+5)*4)-(40/2)-10)"
MsgBox Eval(myString)
thanks guys. u really helped a lot. I added Ms Script contorl and it worked perfect. i tried 'Microsoft Access 8.0 Object Library' too but i recived 'error in loading DLL' error at run time. i don't know why
anyway thanks alot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|