dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Convert String to Integer

  1. #1
    Join Date
    Jun 2005
    Posts
    2

    Convert String to Integer

    I need some sort of algorithm or built in function that will take the string "15" and convert it to the integer 15 without fuss, muss or any sort of queerness.

    I really do hate VB6 because it makes my programs not work.

    Thanks for your time.

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    CInt.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I really would like to know what 'fuss, muss and moss' you are refering too...
    If the string is not empty and it is a number, CInt will do. If the string CAN be empty, use Val (which will return 0, if is what you want). If you want to check if the string is a number use IsNumeric.
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  4. #4
    Join Date
    Jun 2005
    Posts
    2
    Not really fuss and muss then eh. I'm learning VB for a class and the teacher knows about as much about the language as we do, so it is notoriously difficult to find reliable information.

    Thanks for your help.

  5. #5
    Join Date
    Jun 2005
    Posts
    40
    Hey, um guys this is VB Classic forum. We aren't talking C++ or C.

    To convert string to integer its int(your string)

    To convert back its str(your integer)

  6. #6
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    Just a little extra info:

    The Cxxx() functions, such as CInt and CStr, honor the settings in the control panel, so the are usually the correct answer when working with user input and output. Val() and Str(), on the other hand, work in a language neutral way, and are generally good for file I/O when a file must be readble regardless of where in the world the user is located.

    Rune
    If you hit a brick wall, you didn't jump high enough!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center