aholloway
15 years agoNew Contributor
Class_Initalize not called when a new instance of class is created in VBscript
The Class_Initalize constructor is not being called when a new instance of class is created in VBscript. Here's some code from my project:
Class TRMTestCases
private objAppClass, objWinClass, objTRMClass
private strFeature
Private Sub Class_Initalize
Set objAppClass = GetApplicationClassInstance
Set objWinClass = GetWinControlsClassInstance
Set objTRMClass = GetTRMClassInstance
strFeature = "TRM"
MsgBox("I'm in Class_Initalize")
End Sub
....other code
End Class
...
Dim myTRMTestCasesInstance
Function GetTRMTestCasesInstance
If (Not IsObject(myTRMTestCasesInstance)) Then
Set myTRMTestCasesInstance = New TRMTestCases
End If
Set GetTRMTestCasesInstance = myTRMTestCasesInstance
MSgBox("I'm in Get....Instance")
End Function
Any ideas on why the constructor's not being called?
Class TRMTestCases
private objAppClass, objWinClass, objTRMClass
private strFeature
Private Sub Class_Initalize
Set objAppClass = GetApplicationClassInstance
Set objWinClass = GetWinControlsClassInstance
Set objTRMClass = GetTRMClassInstance
strFeature = "TRM"
MsgBox("I'm in Class_Initalize")
End Sub
....other code
End Class
...
Dim myTRMTestCasesInstance
Function GetTRMTestCasesInstance
If (Not IsObject(myTRMTestCasesInstance)) Then
Set myTRMTestCasesInstance = New TRMTestCases
End If
Set GetTRMTestCasesInstance = myTRMTestCasesInstance
MSgBox("I'm in Get....Instance")
End Function
Any ideas on why the constructor's not being called?