The VBA CSNG function is listed under the data type conversion category of VBA functions. When you use it in a VBA code, it converts an expression into a single data type. Actually it converts a value into a single-precision floating-point number. You can read more this format from here.
- Expression: The value which you want to convert to a single data type.
To practically understand how to use VBA CSNG function, you need to go through the below example where we have written a vba code by using it:
Sub example_CSNG() MsgBox CSng("699.9999999") End Sub
In the above example, we have used the value 699.9999999 and then we have used the CSNG function to convert that value into a single data type and it has returned 700 in the result.
- If the value specified is a value other than a number or a string which can’t be recognized as a number, VBA will return the run-time 13 error.