|DIAdem 2015 Help|
|DIAdem 2017 Help|
|DIAdem 2018 Help|
|DIAdem 2019 Help|
|DIAdem 2020 Help|
Use the Set statement to assign an object reference to a variable.
Set ObjectVar = ObjectExpression | New ClassName | Nothing
|ObjectVar||Name of the variable according to the standard conventions.|
|ObjectExpression||Expression that consists of an object name, another object variable, or a function or method that returns and object. .|
|New ClassName||Expression with which you create a new instance of the ClassName class. You can define a class using the Class statement. If ObjectVar already contains a reference to an object, this reference is released as soon as the new reference is assigned.|
|Nothing||Keyword that cancels the assignment of the object variables to the object. If there are no further references to this object, you also release the system resources and the memory resources.|
With the Dim statement, you declare one variable. If you want this variable to refer to an object, use the Set statement to create a reference to the object. You also can define several object variables that simultaneously refer to the same object. If you change the object, these changes always affect all variables that refer to this object.
The following example shows how you can generate an object of the FileSystemObject class, use it, and then release it:
Dim FSO, bExists Set FSO = CreateObject("Scripting.FileSystemObject") bExists = FSO.FileExists("C:\Autoexec.bat") Call MsgBox(bExists) ' further instructions Set FSO = Nothing