Original message moved by ebgreen Reason : Moved to proper forum Set is supposed to set object reference to variable, I understand that Set objFSO = CreateObject("Scripting.FileSystemObject") Creates new instance of Scripting.FilesystemObject class (we create object)
But why do we use Set bellow, do we set reference to object method output also? Set objTextFile = objFSO.OpenTextFile("c:\scripts\service_status.txt", ForAppending, True)
"Set" indicates the assignment, not the creation of an object. Cf:
Set reX = New Regexp Set wmi = GetObject("winmgmts:")
The .OpenTextFile method returns an object that is assigned to the receiving variable, hence "Set".
If you write a function returning an object, don't forget the "Set", when you assign the object to be returned to the 'return value' (same name as the function):
Function getRE( ... ) ... Set getRE = ... End Function