What if i wanted to take the integer 2, and turn it into the string "2", how do I do that?
Printable View
What if i wanted to take the integer 2, and turn it into the string "2", how do I do that?
I'm not sure of what exactly is being asked but:
Code:Dim i As Integer
Dim newstring As String
For i = 0 To 60
If i = 2 Then
newstring = i
MsgBox newstring
Exit Sub
End If
Next i
Hope that helps,
D!m
[Edited by Dim on 09-13-2000 at 08:44 PM]
like if i wanted to do this:
Dim x as Integer
then somewhere in my code, do something like this:
x = 5
x as String
so, then x would no longer be 5 , it would be "5"
how would that get done?? is there a simpler way than the above?
If you truly want a single variable to first be an Integer then later be a String, you have to think about using Variant type.
Look in the help about how to tell what the Variant is representing at any one time.
But if you are really just wanting to cast (convert) an integer to a string, then use the CStr function (It means Convert To String)Code:Dim x as Variant
'Both of the following are valid for a variant
x = 5
x = "5"
RegardsCode:Dim x as Integer
If CStr(x) = "5" Then Debug.Print "Well this should work!"
Paul Lewis