Results 1 to 5 of 5

Thread: string to int

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    string to int

    long time no see guys haha

    quick quesiton, i've completely forgotten since my vb days

    i have a string containing a number, how do i put that value into an integer again?

    thanks

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Just straight assignment will work, ie:
    Dim c As String
    Dim f As Long

    c = "123"
    f = c
    MsgBox f
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Dim tempcheck As Long
    tempcheck = p.data(12)

    type mismatch

    data is an array of strings

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    then just do VAL()

    or other:

    CLNG
    INT
    CINT
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    If you are getting a type mismatch error than p.Data(12) contains character data and cannot be converted to a number.

    CLng or CInt would cause the same error.

    Val will not cause an error but the results may be incorrect.

    Val("123D") - returns 123

    Val("D123") - returns 0

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