The functions that return a String data type will generate an an error if you call them with a value that is Null.
The functions that return a Variant data type can handle Null values without an error.
The functions that do not include a dollar sign can handle Null.
The functions that include a dollar sign ($) cannot handle Null and can only accept Strings.
If you want to be able to handle passing Null into the LEFT function you must pass the results to a Variant data type.
Dim vVariant1 As Variant
Dim vVariant2 As Variant
vVariant1 = Left(Null, 3) 'returns Null
vVariant2 = Left$(Null, 3) 'ERROR invalid use of Null
You should try and avoid using the Variant data type though, unless there is no alternative.
A better approach would be to pass the results into a String data type and prevent a Null argument altogether.
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext