Home

VBA Data Types: Variant

 

Introduction

The VBA language provides a universal (or vague) data type you can use for any type of value. The Variant data type is used to declare a variable whose type is not explicitly specified. This means that a Variant data type can hold any type of value you want.

Here are examples of Variant-declared variables that hold different types of values:

Sub Exercise()
    Dim FullName As Variant
    Dim EmploymentStatus As Variant
    Dim HourlySalary As Variant
    Dim DateHired As Variant
    
    FullName = "Patricia Katts"
    EmploymentStatus = 2
    HourlySalary = 35.65
    DateHired = #6/22/2004#
End Sub
 
 
     
 

Home Copyright © 2009-2010 FunctionX, Inc.