![]() |
RaiseEvent Problem
In my study of RaiseEvent, I have a Question.
I have 2 Textboxes in UserForm1: TextBox1, TextBox2 When I run, Event is fired only on TextBox2. TextBox1 does not fire Event. What is the problem?? my codes... ---(Class1 module)----- Private WithEvents mTx As MSForms.TextBox Public Event F1Pressed() Public Property Set Control(ByRef Ctl As MSForms.TextBox) Set mTx = Ctl End Property Private Sub mTx_KeyDown( _ ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If Shift Then Exit Sub RaiseEvent F1Pressed End Sub --(UserForm1 module)--------- Private Col As VBA.Collection Private WithEvents myCls As Class1 Private Sub UserForm_Initialize() Dim Ctl As Control Set Col = New VBA.Collection For Each Ctl In Controls If TypeOf Ctl Is MSForms.TextBox Then Set myCls = New Class1 Set myCls.Control = Ctl Col.Add myCls End If Next End Sub Private Sub myCls_F1Pressed() MsgBox "F1 Clicked" End Sub |
All times are GMT +1. The time now is 02:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com