IsObject - VBScript


The IsObject command in VB Script examines a given value and determines whether it represents an object. This is useful for verifying the type of a variable or for ensuring that an object is valid before using it.



| Parameter | Description |
| expression | The value to be evaluated. |


This command does not support any options or flags.


  1. Checking if a variable is an object:
Dim x
x = CreateObject("Scripting.FileSystemObject")
If IsObject(x) Then
  WScript.Echo "x is an object."
End If
  1. Validating an object before using it:
Dim fso
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
  WScript.Echo "Could not create the FileSystemObject object."
ElseIf IsObject(fso) Then
  WScript.Echo "The FileSystemObject object is valid."
End If

Common Issues

  • Type mismatch: The expression argument must be a value. If it is not, a type mismatch error will occur.
  • Invalid object: If the expression argument represents an invalid object, the command will return False.
  • Uninitialized object: If the expression argument represents an uninitialized object, the command will return False.


The IsObject command can be combined with other VB Script commands to perform advanced tasks:

  • Use IsObject to check if a variable is an object before using it with other object-oriented commands.
  • Use IsObject to validate objects before passing them to functions or procedures.
  • Use IsObject to determine the type of a value at runtime.
  • GetObject
  • CreateObject
  • GetType