Article ID: 138065
Article Last Modified on 7/1/2004
If blnNotCreated Then Err.Raise vbObjectError, "MyServer", _
"Object Not Yet Created! Please Call the Create Method First"
This will raise an error that is returned back to the client in case the
Create Method is not called. Note also that the flag blnNotCreated is the
only member that is set in the Initialize event. This is done to avoid the
following action, which would result in the unnecessary overhead of the Not
operator:
If Not blnCreated then Err.Raise
Private intData As Integer
Private strData As String
Private blnNotCreated
Public Function Create(param1 As Integer, param2 As _
String) As Boolean
blnNotCreated = False
intData = param1
strData = param2
End Function
Public Sub MyMethod()
If blnNotCreated Then Err.Raise vbObjectError, _
"MyServer", "Object Not Yet Created! Please Call _
the Create Method First"
MsgBox strData
End Sub
Private Sub Class_Initialize()
blnNotCreated = True
End Sub
Private Sub Form_Click()
Dim x As New MyServer.Class1
x.Create 7, "hello"
x.MyMethod
End Sub
Keywords: kbhowto kbcode KB138065