Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if object exists

Status
Not open for further replies.

johnaregan

Programmer
Mar 13, 2001
87
How do you test if an object exists?
 
What type of object? I think that a little more detail is required for an answer.
 
Hi johnaregan,

You can check this with ISOBJECT() function.
But the problem you might face is that this function returns True even if the variable is set to nothing.
 
If you are just checking to see if a variable (i.e. a pointer) is set to an object or not, use the is nothing command. For example

Code:
If not myObject
Code:
is nothing
Code:
 then
    '** Do something with the object.
end if
- Jeff Marler B-)
 
If you want to see if the component is registered then
Code:
Dim objW as object
Dim lngErr as long
On Error Resume Next
    Set objW = CreateObject("scripting.FileSystemObject")
    lngErr = Err.Number
On error goto 0
if LngErr <> 0 then
    ... object is not registered
End if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top