Results 1 to 4 of 4

Thread: Changing a string to an integer

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    In the MSDN files, it says that you can convert a string to an integer if the string is in an integer format. Here is what it says you can do:

    Code:
    strprice = "100.00"
    intprice = strprice
    This code works, but I need something different. What I need to do is something more like this:

    Code:
    For i = 0 to 5
        strprice = MSHFlexgrid.TextMatrix(i, 4)
        intprice = strprice
    Next i
    However, when I do that, it gives me an error because the datatypes are different. What can I do to fix this problem?


    ------------------
    Ryan

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    Post

    Why don't you just convert it into an integer the good ol' fashioned way (Cint(String Expression)) and then use the format function to convert it to whatever (in this case, Format(Cint(String Expression), "####0.00").

  3. #3
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    ACTUALLY the 'good 'ol fashion way' would be simply this:
    Val(String)
    Simple ain't it!
    And a integer to a string?
    Str(Integer)
    Just as simple!

    ------------------
    DiGiTaIErRoR
    VB, QBasic, Iptscrae, HTML
    Quote: There are no stupid questions, just stupid people.

  4. #4

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Thanks, it works great now!

    ------------------
    Ryan

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