|
-
Apr 28th, 2004, 04:30 PM
#1
Thread Starter
New Member
string to operator
Lets say that I have a string - inside the string is a sum that reads 3 + 4
Now I read the string a char at a time and know how to sperate the int values, but is it possible to convert the + operator so that I can get VB.net to carry out this sum? just as I can convert strings into a int32 value, can I convert the + into a operator value?
Any help would be cool
thanks :-)
-
Apr 28th, 2004, 07:43 PM
#2
PowerPoster
Hi,
When reading each character and you come to a number, store the number in the first element of a numerical array. If the next character is also a number, multiply the stored array value by 10 and add the next number. Continue until you get to an arithmetical operator and then store that in the first element of a string array. Similarly, store the next number characters in the second element of the numerical array. Repeat the process until the end of the string.
You then take the first element of the numerical array and apply the operator contained in the first element of the string array to it and the number in the second element of the numerical array etc.
You will have to amend this so as to apply correct arithmetic preference when you come accross multiple calculations.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|