TypeName (function)




Returns the type name of the specified variable.


The returned string can be any of the following:


Returned String

Returned if varname is



A String.



A data object variable. In this case, objecttype is the name of the specific object type.



An integer.



A long.



A single.



A double



A currency value.



A date value.



A boolean value.



An error value.



An uninitialized variable.



A variant containing no valid data.



An OLE automation object.



An unknown type of OLE automation object.



An uninitialized object variable.



A specific type of OLE automation object. In this case, class is the name of the object as known to OLE.


If Varname is an




the returned string can be any of the above strings follows by a empty parenthesis. For example, "Integer()" would be returned for an array of integers.



the expression is evaluated and a String representing the resultant data type is returned.


OLE collection

TypeName returns the name of that object collection.


'The following example defines a subroutine that only accepts

'Integer variables. If not passed an Integer, it will inform

'the user that there was an error, displaying the actual type

'of variable that was passed.

Sub Foo(a As Variant)

  If VarType(a) <> ebInteger Then

    MsgBox "Foo does not support " & TypeName(a) & " variables"

  End If

End Sub

See Also

TypeOf (function)

More information