Set statement
Assign an object reference to a variable or property, or associate an object reference with an event.
Set objectvar = {objectexpression | New classname | Nothing
}
Or
Set object.eventname = GetRef(procname)
Parameters
Objectvar
Required, variable or attribute name, conforming to standard variable naming convention.
Objectexpression
Optional, expression that match the name of the object, another declared variable of the same object type, function, or method, which returns an object of the same type.
New
The keyword that is used to create a new instance of a class. If objectvar contains a reference to an object, the reference is freed when a new reference is assigned to the object. The New key is only used to create an instance of class.
ClassName
Options available. The name of the class that was created. Use The class statement to define a class and its statements.
Nothing
Options available. Disconnects the Objectvar from any specified object or class. When no other variable references the preceding reference object, assign the Objectvar to Nothing to free the system or memory resources associated with the preceding reference object.
Object
Required option. The name of the object associated with the event.
Event
Required option. The event name of the function scope.
ProcName
Required option. A string that contains the name of the Sub or Function associated with the event .
Description
For this to work,Objectvar must be consistent with the assigned object type.
Dim, Private, public, or ReDim statements declare only a variable that refers to an object. In use. No actual object can be referenced until the Set statement assigns a value to a specific object.
Typically, a copy of the object of that variable is not created until you use the Set statement to assign an object reference to a variable. In fact, only a reference to an object was created. Multiple Reference object variables can refer to the same object. Because these variables are references to objects rather than to objects, any changes made in an object can be reflected in all variables that reference that object.
Function ShowFreeSpace(drvPath) Dim fso, d, s Set fso = CreateObject("Scripting.FileSystemObject") Set d = fso.GetDrive(fso.GetDriveName(drvPath)) s = "Drive " & UCase(drvPath) & " - " s = s & d.VolumeName & "<BR>" s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0) s = s & " Kbytes" ShowFreeSpace = sEnd Function
With the New keyword, you can create an instance of a class at any time and assign an object reference variable to it. Variables assigned to instances of a class must be declared in the Dim (or similar statement) statement in advance.
For more information about associating a procedure with an object using the Set statement, refer to the documentation for the GetRef function.