PDA

View Full Version : Convert Integer to String



WizHock
07-31-2008, 07:35 AM
Silly Question:

I know in Visual Studio there is the .ToString() function which allows the conversion of a non-string data type to be converted to a String. What is the equivalent, if any, in VBA? I've searched the Help a little, but don't really have the time to do the leg work on that on.

Thanks in advance.

Dave
07-31-2008, 08:31 AM
HTH. Dave

Dim Num As Double, Str As String
Num = 1000.34
Str = Num
MsgBox Str

CreganTur
07-31-2008, 09:25 AM
You can also use Type Conversion Functions, which are built into VBA to change the data type of anything.

Search the VBA Help File for "Type Conversion Functions" for the whole list.

For your example:

Dim i As Long
i = 100
Left (CStr(i),1)
The above takes a Long type number (i) and converts it into a string just for the Left function.

WizHock
07-31-2008, 08:20 PM
Yea CStr() does the job. I knew there was something similar to .ToString() but I've only briefly, six years ago, worked with VB 6 so I couldn't remember.

Thanks!!

Dave
08-01-2008, 06:01 AM
Thank you's for the info. Have a nice day. Dave