Retrieving INT value of string

Jay1b

Contributor
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
Hi

I am interested in trying to find how out how to find the integer value of a string. We use this at work in ingres, so i am sure it can be done with VB.NET, i just dont know how :)

Thanks.
 
You can use the oldy VAL sentence:
Visual Basic:
'This will return an integer = 123
Val("123")
'So will this...
Val("123sdlfkjs")

'But note that this will still return an integer but = 0
Val("sdlfkjs123")
Alex :D
 
Thanks, but i tried that, but the integer returned was always 0, kind of negating the point of it.

The reason why i want to do this, is because we use this method to encrypt our passwords in our ingres programs, and i need to create a .NET interface, and it would be ideal if i could use the same mechanism.
 
It only returns 0(zero) if the numbers aren't at the begining of the string like I've shown in the examples...
Take a closer look at my examples...

If in other hand, you whant to retrieve numbers that are at other place on the String than the bigining it can be donne but with more lines of code...

Alex :D
 
Visual Basic:
  MsgBox(Val("34hello"))

Returns 34, whereas the true integer value is probably something like 467347887.

Visual Basic:
  MsgBox(Val("hello"))

Returns 0, where again the true integer value would be something nearer 3746473.
 
Ho ... now I got it...

You can use the:
Visual Basic:
"hello".GetHashCode
It retrieves an HashCode based on your String...

Alex :D
 
Thank you. That very very near to what i need. That does return an integer but not the same integer as UNIX returns for a test string. :(
 
Back
Top