Microsoft® Visual Basic® Scripting Edition Initialize Event |
Language Reference Version 5 |
Occurs when an instance of the associated class is created.
Private Sub Class_Initialize()
statements
End SubThe statements part consists of zero or more code statements to be run when the class is initlized.
The following example illustrates the use of the Initialize event:Class TestClass Private Sub Class_Initialize ' Setup Initialize event. MsgBox("TestClass started") End Sub Private Sub Class_Terminate ' Setup Terminate event. MsgBox("TestClass terminated") End Sub End Class Set X = New TestClass ' Create an instance of TestClass. Set X = Nothing ' Destroy the instance.