Determining the Type of a Variant : Variant « Data Type « VBA / Excel / Access / Word

Home
VBA / Excel / Access / Word
1.Access
2.Application
3.Data Type
4.Data Type Functions
5.Date Functions
6.Excel
7.File Path
8.Forms
9.Language Basics
10.Math Functions
11.Outlook
12.PowerPoint
13.String Functions
14.Windows API
15.Word
16.XML
VBA / Excel / Access / Word » Data Type » Variant 
Determining the Type of a Variant
 
Value     Variant type
0     Empty (unitialized)
1     Null (no valid data)
2     Integer
3     Long Integer
4     Single
5     Double
6     Currency
7     Date
8     String
9     Object
10     Error value
11     Boolean
12     Variant (only used with arrays of variants)
13     Data access object
14     Decimal value
17     Byte
36     User Defined Type
8192           Array

Sub VariantExample()
    Dim varAnyThing As Variant
    
    varAnyThing = 12.345
    Debug.Print VarType(varAnyThing)
    
    varAnyThing = 12.345
    varAnyThing = varAnyThing & " is a number"
    Debug.Print VarType(varAnyThing)
     
     varAnyThing = 12.345
     varAnyThing = varAnyThing + "10"
     Debug.Print VarType(varAnyThing)
     
     varAnyThing = 12345
     Debug.Print VarType(varAnyThing)
     
     varAnyThing = 123456
     Debug.Print VarType(varAnyThing)
End Sub

 
Related examples in the same category
1.If you simply declare a variable with a Dim statement and leave off the type-declaration keyword or character, the variable is a variant
2.Variant string
3.A Variant allows VBA to make its own decision as to what type of data it is holding
4.Get the variable type for Variant
5.One of the few instances in which you have no choice for using a Variant:
6.A Variant allows VBA to make its own decision as to what type of data it is holding: string and integer
7.Assign difference type variable to Variant variable
8.Add Variant integer to Variant string
9.Add Variant string to Variant integer
10.Add Variant integer in string to another Variant integer in string
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.