Search notes:

VBA: cStr

cStr(arg) is a conversion function and converts arg into a string data type.
The format of the string is dependent on the data type of arg which I try to demonstrate with the following simple example:
option explicit

sub main() ' {

    dim bl as boolean
    dim dt as date
    dim em as variant ' Without assignment, a variant variable has teh value empty.
'   dim er as error
    dim nl as variant
    dim nm as long

    dt = 123456.789
    nl = null
    nm = 42

    debug.print cStr(bl ) ' False
    debug.print cStr(dt ) ' 03/01/2238 18:56:10
    debug.print cStr(em ) '
    debug.print cStr(err) ' 40040
 '  debug.print cStr(nl ) ' runtime error '94': Invalid use of Null
    debug.print cStr(nm ) ' 42

end sub ' }
Github repository about-VBA, path: /functions/conversion/cStr.bas

Index