CStr

Coerces an expression to a String.

Syntax: CStr( expression )

expression
required Any valid expression.

The return type is String. The result depends on the type of expression:

If expression is CStr returns
Boolean A string containing "True" or "False".
Date A string containing a date in the short date format of your system.
Empty A zero-length string ("").
Error A string containing the word Error followed by the error number.
Null A run-time error.
Other numeric A string containing the number.

Use CStr instead of Str to provide internationally aware conversions from a number to a string. CStr recognizes different decimal separators properly, depending on the locale setting of your computer.

Example

This example uses the CStr function to convert a numeric value to a String.

Dim MyDouble, MyString
MyDouble = 437.324                       ' MyDouble is a Double.
MyString = CStr(MyDouble)                ' MyString contains "437.324".

See Also

License: CC-BY-4.0 Code license: MIT Attribution: VBA-Docs