VBA CVar function

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

CVar Function Description

The VBA CVar function converts an expression (variable) to Variant data type.

Syntax

The syntax for the CVar function in VBA is:

CVar( expression )

Parameters

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

Other Notes

The Variant data type is the default data type for undeclared variables. Using it is inefficient and may result in your VBA running much slower. Read more here (item 12 in table)

Example usage

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

CVar "10"
'Result: "10" (Variant/String)

CVar 10
'Result: 10 (Variant/Integer)

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