Table of contents
TOC
Collapse the table of content
Expand the table of content

TypeName Function

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Returns a String that provides information about avariable. SyntaxTypeName(varname) The required varnameargument is aVariant containing any variable except a variable of auser-defined type. Remarks The string returned by TypeName can be any one of the following:

String returnedVariable
object typeAn object whose type is objecttype
ByteByte value
IntegerInteger
LongLong integer
SingleSingle-precision floating-point number
DoubleDouble-precision floating-point number
CurrencyCurrency value
DecimalDecimal value
DateDate value
StringString
BooleanBoolean value
ErrorAn error value
EmptyUninitialized
NullNo valid data
ObjectAn object
UnknownAn object whose type is unknown
NothingObject variable that doesn't refer to an object

If varname is anarray, the returned string can be any one of the possible returned strings (or Variant ) with empty parentheses appended. For example, if varname is an array of integers, TypeName returns "Integer()".

Example

This example uses the TypeName function to return information about a variable.

' Declare variables.
Dim NullVar, MyType, StrVar As String, IntVar As Integer, CurVar As Currency
Dim ArrayVar (1 To 5) As Integer
NullVar = Null    ' Assign Null value.
MyType = TypeName(StrVar)    ' Returns "String".
MyType = TypeName(IntVar)    ' Returns "Integer".
MyType = TypeName(CurVar)    ' Returns "Currency".
MyType = TypeName(NullVar)    ' Returns "Null".
MyType = TypeName(ArrayVar)    ' Returns "Integer()".
© 2017 Microsoft