CStr function
Returns an expression that has been converted to a Variantof String subtype.
CStr(expression)
The expression parameter is any valid expression.
Description
In general, you can use a subtype conversion function to write code to show that the results of some operations should be represented as a specific data type, not the default type. For example, use CStr to force the result to be represented as a String.
The CStr function is used to override the Str function for internationally recognized format conversions from other data types to String subtypes. For example, the recognition of the decimal separator depends on the locale of the system.
expression determines the data returned according to the following table:
If expression is |
CStr return |
Boolean |
A string that contains True or False. |
Date |
A string that contains the system's short date format date. |
Null |
Run-time error. |
Empty |
0 Length string (""). |
Error |
string that contains the word error following the error number. |
Other values |
A string containing this number. |
The following example converts a number to a Stringusing the CStr function:
Dim mydouble, mystringmydouble = 437.324 ' MyDouble
is a double value. MyString = CStr ( mydouble ) ' MyString
Contains the 437.324
.