Hi All
I have a string with me. like "12345". This I want to convert to absolute int value of it i.e. 12345 as int.
How can I do the same ?
pls advice asap
Thanks in advance,
Nahush
Printable View
Hi All
I have a string with me. like "12345". This I want to convert to absolute int value of it i.e. 12345 as int.
How can I do the same ?
pls advice asap
Thanks in advance,
Nahush
use function "cint()"
VB Code:
Dim myInt as Integer myInt = CInt("12345")
CInt converts to Integer datatype, the maximum value is 32767. If you need a longer range, use Long datatype instead (CLng). It'll allow numbers up to 2 147 483 647.
Note that you will get an error if you try to pass a string that doesn't contain numbers or that contains something else than numbers. If you want more "freedom", use Val() to first convert to a number and then CLng() to convert to Long datatype.
VB Code:
Dim lngTest As Long lngTest = CLng(Val(Text1.Text))