Results 1 to 4 of 4

Thread: URGENT : String to Int conversion

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    4

    Question 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

  2. #2
    Fanatic Member
    Join Date
    Jul 2006
    Location
    nasik,india
    Posts
    909

    Re: URGENT : String to Int conversion

    use function "cint()"

  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: URGENT : String to Int conversion

    VB Code:
    1. Dim myInt as Integer
    2. myInt = CInt("12345")
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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:
    1. Dim lngTest As Long
    2.     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
  •  



Click Here to Expand Forum to Full Width