How do I make a function return a class?
I'm doing this in order to implement a better error handling routine in my code:
---> Class cMensagens:
Private mvarMsg As String
Private mvarRes As Boolean
Public Property Get Msg() As String
Msg = mvarMsg
End Property
Public Property Let Msg(ByVal vMsg As String)
mvarMsg = vMsg
End Property
Public Property Get Res() As Boolean
Res = mvarRes
End Property
Public Property Let Res(ByVal vRes As Boolean)
mvarRes = vRes
End Property
--> Form:
Private Function CanFinish(idT As Long, numO As Integer) As cMensagens
...
If rst.EOF Then
CanFinish.Res = False 'PROBLEM HERE!!!
CanFinish.Msg = "Error message"
End If
End Function
But I always get the "Object Variable or With block variable not set" error when I try to set the return values of the function. What am I doing wrong?
Thanks!
Rui
|