|
-
Sep 13th, 2000, 07:33 PM
#1
What if i wanted to take the integer 2, and turn it into the string "2", how do I do that?
-
Sep 13th, 2000, 07:41 PM
#2
Fanatic Member
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]
-
Sep 13th, 2000, 07:49 PM
#3
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?
-
Sep 13th, 2000, 08:21 PM
#4
Hyperactive Member
You can only do that with Variant
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.
Code:
Dim x as Variant
'Both of the following are valid for a variant
x = 5
x = "5"
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 Integer
If CStr(x) = "5" Then Debug.Print "Well this should work!"
Regards
Paul Lewis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|