|
-
Mar 24th, 2000, 05:50 AM
#1
Thread Starter
Frenzied Member
I am trying to get a numberic value of a string variable that is , for example "3 + 6 + 7 - 9 * 2"
What I want this to do is evaluate this as a mathematical value and assign it to a number value
The following does not work
dblValue = Val(strEquation)
This value gets returned as the first number in the sequence of the string variable (in this case it will equal 3)
I also tried removing the spaces as well as putting in parentheses. It doesn't work.
Is there another way or something I'm missing? It would really help me out. Thanks.
-
Mar 24th, 2000, 06:05 AM
#2
transcendental analytic
You will have to make a script that reads those strings and calculates them manually.
-
Mar 24th, 2000, 06:16 AM
#3
Frenzied Member
There's something called uMath which can do it, I think it's about $100 but it's damn usefull if you need to do a lot of this stuff, otherwise, program your own. VB can't do it, I don't know where uMath is but search under Maths parser.
-
Mar 24th, 2000, 06:40 AM
#4
New Member
the val() function converts every digit until it encounters the first non-digit number. Valid characters aree 0-9 the sign (+ or -) and the decimal point(.)
to convert a string to a mathmatical sequence try the eval() method. It evaluates a supplied string as though it were code. As a result, you could easily evaluate mathematical expressions passed as a string, like so:
iResult = Eval("(2 * 3) + 5)")
which fills iResult with the value 11.
-
Mar 24th, 2000, 03:26 PM
#5
Thread Starter
Frenzied Member
Yes I would like to see the code if you can share it, thanks.
I have done some code that does this thing, but I think it's a bit slow for use. Interested?
-
Mar 24th, 2000, 07:38 PM
#6
transcendental analytic
The module is at:
http://www.geocities.com/kedasu/varol.bas
It's somewhat old, I haven't used it for years. Don't worry about those swedish comments. If anyone finds it useful or finds any bugs, reply here or contact me
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
|