CStr Function
Return expression, which has been convertedStringChild typeVariant.
CStr(expression)
ExpressionThe parameter is any valid expression.
Description
Generally, code can be written using a subtype Conversion Function to show that the results of some operations should be represented as specific data types, rather than the default type. For exampleCStrForcibly express the resultString.
CStrFunction used to replaceStrFrom other data typesStringSub-types are internationally recognized for format conversion. For example, the identification of the decimal separator depends on the system's region settings.
ExpressionThe returned data is determined based on the following table:
| If expression is |
CStr return |
| Boolean |
String, including True or False. |
| Date |
StringContains the system's short date format date. |
| Null |
Runtime error. |
| Empty |
Zero LengthString(""). |
| Error |
StringContains the word Error with an Error number. |
| Other values |
String, Including this number. |
The following example usesCStrFunction converts a numberString:
Dim MyDouble, MyStringMyDouble = 437.324 ' MyDouble Is a double precision value.MyString = CStr(MyDouble) ' MyString Include "437.324".