Excel CStr Function (VBA)
-function/cstr-function-vba-code.jpg)
How to use the CStr Function (VBA)
This Excel tutorial explains how to use the Excel CStr function with syntax and examples using VBA.
SUMMARY:
The Excel VBA CStr function converts an expression into a String data type.
For example,
- The VBA Code CStr("Hello") would return "Hello"
- The VBA Code CStr(33.955555) would return "33.955555"
PURPOSE:
To converts a value to a String.
RETURN VALUE:
The CStr function returns a String value.
SYNTAX:
CStr( expression )
ARGUMENTS:
The CStr function syntax has the following arguments:
- expression: Required. The expression is that you want to convert to a String data value.
- If "expression" is outside the range of the data type being converted to, an error occurs.
- If the expression can be interpreted as a date it returns a string representation of that date.
REMARKS:
- The CStr function can only be used in VBA code in Microsoft Excel.
- The CStr Function can convert different types of expression (Integer, Boolean and Date) into String data types
- You can use the CStr function if you want to return a numerical values as a string.
- The Single data type is a Value data type.
- VBAs hexadecimal notation symbol is "&H"