|
-
July 12th, 2001, 03:56 PM
#1
Calculating string sums
I would like to know if there is any function in VB by which you can 'parse' a string containing a sum, like "1+1", and get a number containing the result. JavaScript has the eval() function which you can use for this purpose, but I have not been able to find any such function in VB. Any help would be greatly appreciated!
-
July 12th, 2001, 04:08 PM
#2
Re: Calculating string sums
I am not sure if there is any function in VB to do so, but I can create a simply one by using Split() function. As following:
===
Private Function GetSum(strTheSumString As String) As Long
Dim str() As String
Dim intRV As Integer
str = Split(strTheSumString, "+")
intRV = CInt(str(0)) + CInt(str(1))
GetSum = intRV
End Function
===
Good luck!
Regards,
Michi
MCSE, MCDBA
-
July 12th, 2001, 05:51 PM
#3
Re: Calculating string sums
Try this link it seems to do ehat you need!
http://www.freevbcode.com/ShowCode.Asp?ID=1263
Kris
Software Engineer
Phoenix,AZ
Kris
Software Engineer
Phoenix, AZ USA
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
|