Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Returns a String that provides information about a variable.

Syntax

TypeName ( varname )

The required varnameargument is a Variant containing any variable except a variable of a user defined type.

Remarks

The string returned by TypeName can be any one of the following:

String returned

Variable

Object type

An object whose type is objecttype

Byte

Byte value

Integer

Integer

Long

Long integer

Single

Single-precision floating-point number

Double

Double-precision floating-point number

Currency

Currency value

Decimal

Decimal value

Date

Date value

String

String

Boolean

Boolean value

Error

An error value

Empty

Uninitialized

Null

No valid data

Object

An object

Unknown

An object whose type is unknown

Nothing

Object variable that doesn't refer to an object


If varname is an array, 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

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

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

Dim NullVar, MyType, StrVar As String
Dim 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()".

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×