Results 1 to 4 of 4

Thread: Conversion functions

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Sydney, NSW, Australia
    Posts
    3

    Post

    This may not really be conversion as such, but is there any way to take the value of a string and convert it to a integer?

    ie string contains "12345"
    I want to make it an int, with value 12345.

    Please help

  2. #2
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Post

    Code:
    Option Explicit
    Dim MyString As String
    Dim MyInteger As Integer
    Dim MyNumber As Double
    
    
    Private Sub Form_Click()
        MyString = "12345"
        MyInteger = Val(MyString)
        Print MyString
        Print MyInteger
        
    End Sub

    [This message has been edited by johnpc (edited 01-12-2000).]

  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi,Eagle.
    Why not to use CInt function?
    It will convert your string to integer.

    Dim MyStr As String
    Dim i As Integer

    MyStr = "12345"
    i = CInt(MyStr)

    Larisa

  4. #4
    Lively Member
    Join Date
    Jul 1999
    Posts
    99

    Post

    There is also:

    CLng() to convert to Long
    CInt() to convert to Integer
    CSng() to convert to Single
    CDbl() to convert to Double

    You can always check vb help or MSDN. i'm sure you can find answers to your common questions there.

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