Returning the value of a string (like val(string) )

Maartensaps

Member
Licensed User
Longtime User
I used to program in Clipper and Qbasic and in those there was a simple way to return the value of a string (if the string contains digits)
It was VAL(string) and it would return the value of "string" starting at the first character, until the last or until the first non-digit-character.
Basically it is the opposite of CHR(int)

I would like to use it to convert stored strings (in a preference file) back to its numbers.
Now I use a sub that compares and returns, but with multi-digit strings this becomes quit complex. Especially if a decimal sign is used.:BangHead:

Did I miss it? or is it not there?
And... will it be there in the future ?

Maarten
 
Great !!!

Isn't life amazing.

And I was building complicated subroutines with iterations that tested for numbers and decimal points etc etc etc... duh!

Thanks!
 
Code: Copy
Dim i As Int = "34 * 2"   'Not valid
Code: Copy
Dim i As String = "34 * 2"   'returns: 34*2
Code: Copy
Dim i As String = "34 * 2"
Dim Member() As String 
Member=Regex.Split("\*",i) 
Msgbox(Member(0) *Member(1),"")  'returns 68
Code: Copy
Dim i As Int = "34" * 2 'returns 68
Code: Copy
Dim i As Int = "34" * "2" 'returns 68
 
Back
Top