AlexanderBB
Well-known Member
- Joined
- Jul 1, 2009
- Messages
- 1,835
- Office Version
- 2019
- 2016
- Platform
- Windows
I'm creating a number of List Boxes at run time, depending on Side
This is working ok, but I've struck unknown territory adding their Click Event code.
After some googling I've managed to get one listbox event working. In Module Declarations I have Public ObjEvents() As New clsEvents.
Then after the line above where cControl is Set
Then in class module
How can I modify this so it works with all Listboxes, "lst1", "lst2" etc. as per value of Side ?
Thanks for any help. First time using WithEvents.
VBA Code:
Set cControl = MyForm.Frame1.Controls.Add("Forms.ListBox.1", "lst" & Side, True)
After some googling I've managed to get one listbox event working. In Module Declarations I have Public ObjEvents() As New clsEvents.
Then after the line above where cControl is Set
VBA Code:
Set ObjEvents.lbEvents = cControl
VBA Code:
Option Explicit
Public WithEvents lbEvents As MSForms.ListBox
Private Sub lbEvents_Click()
MsgBox "Clicked"
End Sub
How can I modify this so it works with all Listboxes, "lst1", "lst2" etc. as per value of Side ?
Thanks for any help. First time using WithEvents.