I have one form with four CommandButtons putted in an array (Cmd(0), Cmd(1), …)
I have also one class which operate with these buttons. I have a problem, how to pass reference of button array to one class's method.
Example:
Class clsBtn:
Private mBtn(4) As CommandButton
Friend Sub AddButtons(ByRef a_btn() As CommandButton)
Set mBtn = a_btn
End Sub
Form form1:
Private cBtn as claBtn
Public Sub Form_init()
Set cBtn = new clsBtn
cBtn.AddButtons form1.Cmd
End Sub
This way got error "Array or user defined type expected" at line with cBtn.AddButtons form1.btn
If I reorded above methods and properties this way
Class clsBtn:
Private mBtn1 As CommandButton
Private mBtn2 As CommandButton
Private mBtn3 As CommandButton
Private mBtn4 As CommandButton
Friend Sub AddButton1(ByRef a_btn As CommandButton)
Set mBtn1 = a_btn
End Sub
Friend Sub AddButton2(ByRef a_btn As CommandButton)
Set mBtn2 = a_btn
End Sub
…
Form form1:
Private cBtn as claBtn
Public Sub Form_init()
Set cBtn = new clsBtn
cBtn.AddButton1 form1.Cmd(0)
cBtn.AddButton2 form1.Cmd(1)
…
End Sub
I got RunTimeError 13: Type Mismatch in a line cBtn.AddButton1 form1.Cmd(0).
Can anyone help me? Thanks in advance.
I have also one class which operate with these buttons. I have a problem, how to pass reference of button array to one class's method.
Example:
Class clsBtn:
Private mBtn(4) As CommandButton
Friend Sub AddButtons(ByRef a_btn() As CommandButton)
Set mBtn = a_btn
End Sub
Form form1:
Private cBtn as claBtn
Public Sub Form_init()
Set cBtn = new clsBtn
cBtn.AddButtons form1.Cmd
End Sub
This way got error "Array or user defined type expected" at line with cBtn.AddButtons form1.btn
If I reorded above methods and properties this way
Class clsBtn:
Private mBtn1 As CommandButton
Private mBtn2 As CommandButton
Private mBtn3 As CommandButton
Private mBtn4 As CommandButton
Friend Sub AddButton1(ByRef a_btn As CommandButton)
Set mBtn1 = a_btn
End Sub
Friend Sub AddButton2(ByRef a_btn As CommandButton)
Set mBtn2 = a_btn
End Sub
…
Form form1:
Private cBtn as claBtn
Public Sub Form_init()
Set cBtn = new clsBtn
cBtn.AddButton1 form1.Cmd(0)
cBtn.AddButton2 form1.Cmd(1)
…
End Sub
I got RunTimeError 13: Type Mismatch in a line cBtn.AddButton1 form1.Cmd(0).
Can anyone help me? Thanks in advance.