CSTR(expression)

Returns the expression converted to a string data type (String).


expressionThe expression to evaluate and convert to a string,

REMARKS
* The String data type can contain a fixed length or a variable length string.
* If the expression passed to the function is outside the range of the data type being converted to, an error occurs.
* When the expression is a number this function is identical to the STR function.
* If the expression is a boolean it returns the corresponding string representation "True" or "False".
* If the expression can be interpreted as a date it returns a string representation of that date.
* For numbers its just the value as a string (for example "25").
* You can use the FORMAT function to convert a number or date to a particular format.
* You can use the STR function if you want to return a numerical values as a string.
* You can use the STRCOMP function to return the result of a string comparison.
* You can use the STRREVERSE to return a text string with the characters reversed.
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print CStr(100)          '= "100"  
Debug.Print CStr(10 * 10) '= "100"

Dim dbValue As Double
dbValue = 100.1234
Debug.Print CStr(dbValue) '= "100.1234"

dbValue = 0.123
Debug.Print CStr(dbValue) '= "0.123"

Debug.Print CStr("400 pence") '= "400 pence"
Debug.Print Str("400 pence") ' run-time error

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited Top