TypeName function
Returns a String that provides information about a variable.
Syntax
TypeName(varname)
The required varname argument 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
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()".
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기