VBA CSng function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

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 

Simply the best place to learn VBA!

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match