VBScript TypeNameFunction


VBScript 参考手册Complete VBScript Reference

The TypeName function returns the subtype of a specified variable.

The TypeName function returns the following values:

  • Byte - Represents a byte value
  • Integer - Represents an integer value
  • Long - Represents a long integer value
  • Single - Represents a single-precision floating-point value
  • Double - Represents a double-precision floating-point value
  • Currency - Represents a currency value
  • Decimal - Represents a decimal value
  • Date - Represents a date or time value
  • String - Represents a string value
  • Boolean - Represents a Boolean value, True or False
  • Empty - Represents an uninitialized variable
  • Null - Represents no valid data
  • <object type> - Represents the actual object type name
  • Object - Represents a generic object
  • Unknown - Represents an unknown object type
  • Nothing - Represents an object variable that does not yet reference an object instance
  • Error - Represents an error

Syntax

TypeName(varname)

Parameter Description
varname Required. The name of the variable.

Example

Example

<script type="text/vbscript">

x="Hello World!"
document.write(TypeName(x) & "<br />")
x=4
document.write(TypeName(x) & "<br />")
x=4.675
document.write(TypeName(x) & "<br />")
x=Null
document.write(TypeName(x) & "<br />")
x=Empty
document.write(TypeName(x) & "<br />")
x=True
document.write(TypeName(x))

</script>

The output of the above example is:

String
Integer
Double
Null
Empty
Boolean

Try it Yourself »

VBScript 参考手册Complete VBScript Reference Other Extensions