chrishooper
Technical User
I am trying to adapt some code that i ripped from the web to capture commands from multiple comboboxes in a userform, the ultimate goal being to allow them to utilise the same subroutine.
I have two comboboxes and have set the tags to "1" and "2" and am trying to get the class module to return the tag names in a dialogue box. Here's my code:
MODULE *******
Option Explicit
Dim combos() As New Class1
Sub ShowDialog()
Dim combocount As Integer
Dim ctl As Control
'Create the combo objects
combocount = 0
For Each ctl In UserForm1.Controls
combocount = combocount + 1
ReDim Preserve combos(1 To combocount)
Set combos(combocount).ComboGroup = ctl
Next ctl
UserForm1.Show
End Sub
CLASS MODULE *******
Public WithEvents ComboGroup As ComboBox
Private Sub ComboGroup_click()
MsgBox "Hello from " & ComboGroup.Tag
End Sub
Since i am new to VBA i only have a vague idea of what the code is doing. I wonder if anyone can help me to understand it and find the mistakes.
Thanks in advance, Chris.
I have two comboboxes and have set the tags to "1" and "2" and am trying to get the class module to return the tag names in a dialogue box. Here's my code:
MODULE *******
Option Explicit
Dim combos() As New Class1
Sub ShowDialog()
Dim combocount As Integer
Dim ctl As Control
'Create the combo objects
combocount = 0
For Each ctl In UserForm1.Controls
combocount = combocount + 1
ReDim Preserve combos(1 To combocount)
Set combos(combocount).ComboGroup = ctl
Next ctl
UserForm1.Show
End Sub
CLASS MODULE *******
Public WithEvents ComboGroup As ComboBox
Private Sub ComboGroup_click()
MsgBox "Hello from " & ComboGroup.Tag
End Sub
Since i am new to VBA i only have a vague idea of what the code is doing. I wonder if anyone can help me to understand it and find the mistakes.
Thanks in advance, Chris.