See Also Example
Used to compare two object reference variables.
Syntax
result = objref1 Is objref2
Remarks
If objref1 and objref2 both refer to the same object result is True; if they do not, result is False. Two variables can be made to refer to the same object in several ways:
In the following example, A has been set to refer to the same object as B.
Set A = B
The following example makes A and B refer to the same object as C:
Set A = C
Set B = C
Set Statement
The example uses the Is operator to evaluate if two object reference variables refer to the same form. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Dim A As New Form1 ' Declare new instance of form.
Dim B As Form ' Declare new object reference.
Sub Form_Click ()
If A Is B Then ' Do they refer to same form?
Msg = "A and B refer to the same form."
Else
Msg = "A and B do not refer to the same form."
End If
MsgBox Msg ' Display message.
Set B = A ' Set B to same form as A.
If A Is B Then ' Check again.
Msg = "A and B refer to the same form."
Else
Msg = "A and B do not refer to the same form."
End If
MsgBox Msg ' Display message.
End Sub