I have a form named form1 with one control on it, it is a label named label1
I have a class named Class1.
Followed is the code of form 1 and Class1
form1
====
Option Explicit
Dim cls1 As New Class1
Private Sub Form_Activate()
cls1.setLbl Me.Label1
cls1.test
End Sub
Class1
=====
Dim lbl As Label
Public Sub test()
MsgBox "hello"
Label1.Caption = "test"
End Sub
Public Sub setLbl(lbl1 As Label)
lbl = lbl1
End Sub
When I open form, it prompts me
Run-time error '91':
Object variable or with block variable not set
What is the problem and how to correct it?
I have a class named Class1.
Followed is the code of form 1 and Class1
form1
====
Option Explicit
Dim cls1 As New Class1
Private Sub Form_Activate()
cls1.setLbl Me.Label1
cls1.test
End Sub
Class1
=====
Dim lbl As Label
Public Sub test()
MsgBox "hello"
Label1.Caption = "test"
End Sub
Public Sub setLbl(lbl1 As Label)
lbl = lbl1
End Sub
When I open form, it prompts me
Run-time error '91':
Object variable or with block variable not set
What is the problem and how to correct it?