Set Statement Example

This example uses the Set statement to assign object references to variables. YourObject is assumed to be a valid object with a Text property.

Dim YourObject, MyObject, MyStr
Set MyObject = YourObject    ' Assign object reference.
' MyObject and YourObject refer to the same object.
YourObject.Text = "Hello World"    ' Initialize property.
MyStr = MyObject.Text    ' Returns "Hello World".

' Discontinue association. MyObject no longer refers to YourObject.
Set MyObject = Nothing    ' Release the object.