VBA CSng function

CSng Function Description

The VBA CSng function converts an expression (variable) to Single data type.

Syntax

The syntax for the CSng function in VBA is:

CSng( expression )

Parameters

expression
An expression / variable that is to be converted to Single data type.

Other Notes

If the expression / variable can’t be converted to a Single, the function with return Error code 13: Type mismatch.

Example usage

The CSng function can be used in VBA code. Let’s look at some VBA CSng function examples:

CSng 10
'Result: 10

CSng 10.2
'Result: 10.2

CSng 10.111119
'Result: 10,11112