TypeName Function

Syntax:

TypeName[$](var)

Group:

Variable Info

Description:

Return a string indicating the type of value stored in var.

 

Parameter

Description

var

Return a string indicating the type of value stored in this variable.

 

 

Result

Description

Empty

Variant variable is empty. It has never been assigned a value.

Null

Variant variable is null.

Boolean

Variable contains an integer value.

Byte

Variable contains a single value.

SByte

Variable contains a single value.

Short

Variable contains a byte value.

Integer

Variable contains an Integer value.

Long

Variable contains a long value.

Decimal

Variable contains a Decimal value.

Single

Variable contains a single value.

Double

Variable contains a double value.

Currency

Variable contains a currency value.

Date

Variable contains a date value.

String

Variable contains a string value.

Object

Variable contains an object reference that is not Nothing. (An object may return a type name specific to that type of object.)

Nothing

Variable contains an object reference that is Nothing.

Byte

Variable contains a byte value.

Error

Variable contains a error code value.

Variant

Variable contains a variant value. (Only used for arrays of variants.)

Unknown

Variable contains a non-ActiveX Automation object reference.

( )

Variable contains an array value. The TypeName of the element followed by ( ).

 

See Also:

VarType

Example:


Sub Main
  Dim X As Variant
  Debug.Print TypeName(X) '"Empty"
  X = 1
  Debug.Print TypeName(X) '"Integer"
  X = 100000
  Debug.Print TypeName(X) '"Long"
  X = 1.1
  Debug.Print TypeName(X) '"Double"
  X = "A"
  Debug.Print TypeName(X) '"String"
  Set X = CreateObject("Word.Basic")
  Debug.Print TypeName(X) '"Object"
  X = Array(0,1,2)
  Debug.Print TypeName(X) '"Variant()"
End
Sub