Module 4 - Variables, Parameters and Functions
Lesson 4.1 - Basic Data Variables
Topic 4.1.7 - The Variant Data Type

This page describes how to

Files Needed

You can click here to download the file for this page.

Completed Code

You can click here to download a file containing the sample code.

You can

 

Declaring Multiple Variables in One Line

Rather than using a separate line for each variable, you can declare multiple variables in the same line:

Multi variables

You can write a comma-separated list of variable names and data types in one Dim statement.

You may find this style of declaring variables convenient when you have a group of related variables.  Take care to always state the data type for each variable that you declare.  The code shown below falls into the trap of adding the data type only at the end of the line:

Only one data type

This code looks as though it declares three variables with the Double data type, but it doesn't! Only the last variable, BMI, has the Double data type.  The other two variables will automatically have the Variant data type assigned to them.

 

You can learn more about the Variant data type

To practise

This page has 0 threads Add post