Click to See Complete Forum and Search --> : Conversion functions
Eagle
Jan 11th, 2000, 07:34 AM
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
johnpc
Jan 11th, 2000, 07:57 AM
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).]
LG
Jan 11th, 2000, 10:06 AM
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
Tonio169
Jan 11th, 2000, 04:23 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.