|
-
Aug 18th, 2006, 01:52 AM
#1
Thread Starter
New Member
URGENT : String to Int conversion
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
-
Aug 18th, 2006, 01:56 AM
#2
Fanatic Member
Re: URGENT : String to Int conversion
-
Aug 18th, 2006, 01:56 AM
#3
Re: URGENT : String to Int conversion
VB Code:
Dim myInt as Integer
myInt = CInt("12345")
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Aug 18th, 2006, 02:40 AM
#4
Re: URGENT : String to Int conversion
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))
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
|