Convert Number to String Method
The Convert Number to String method converts a number to a string. It returns a string representation of this number. It uses the following precision in the returned string:
Single-precision for an integer or for a single-precision numeric expression.
Double-precision for a long number or for a double-precision numeric expression.
Currency precision for currency.
A variant returns the precision of the underlying variable type. For more information, see Variants.
Format
Str[$](number)
For information about the dollar sign, see Usage of the Dollar Sign.
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
number |
The number that this method converts to a string. |
Example
The following example prompts the user to enter two numbers. It adds these numbers, and then displays them as a concatenated string:
Sub Button_Click
Dim x as Integer
Dim y as Integer
Dim str1 as String
Dim value1 as Integer
x = 1
y = 2
str1 = "The sum of these numbers is: " & x+y
str1 = Str(x) & Str(y)
End Sub