Compares two object expressions and returns -1 if they refer to the same object, 0 otherwise.
objectExpression Is objectExpression
where: | is: |
objectexpression | Any valid object expression. |
Is can also be used to test if an object variable has been Set to Nothing.
This example displays a list of open files in the software application, VISIO. It uses the Is operator to determine whether VISIO is available. To see how this example works, you need to start VISIO and open one or more documents.
Sub main
Dim visio as Object
Dim doc as Object
Dim msgtext as String
Dim i as Integer, doccount as Integer
'Initialize Visio
Set visio = GetObject(,"visio.application")
' find Visio
If (visio Is Nothing) then
Msgbox "Couldn't find Visio!"
Exit Sub
End If
'Get # of open Visio files
doccount = visio.documents.count
'OLE call to Visio
If doccount=0 then
msgtext="No open Visio documents."
Else
msgtext="The open files are: " & Chr$(13)
For i = 1 to doccount
Set doc = visio.documents(i)
' access Visio's document method
msgtext=msgtext & Chr$(13)& doc.name
Next i
End If
MsgBox msgtext
End Sub