Hi There,
I'm getting some weird behaviour trapping events within a collection class.
The basic structure is
1. A form with 4 TextBoxes.
2. Each TextBox is referenced WithEvents in a class called clsKey.
3. The referenced TextBox.OnFocus Event is used to raise an event called ActivateKey, which has clsKey.Me as the parameter.
4. Each clsKey is referenced WithEvents in the collection object of a class called clsKeys.
Now here's the thing. When any of the TextBoxes get the TextBox.OnFocus event raises the ActivateKey event. However, this event is only trapped in clsKeys if the TextBox is not null.
Here's the code:
|Class clsKey|
Private WithEvents ctlTextBox As TextBox
Public Event ActivateKey(ByVal ActiveKey As clsKey)
Private Sub ctlTextBox_GotFocus()
RaiseEvent ActivateKey(Me)
End Sub
|Class clsKeys|
Private WithEvents objKey As clsKey
Private objActiveKey As clsKey
Private Sub objKey_ActivateKey(ByVal ActiveKey As clsKey)
Set objActiveKey = ActiveKey
End Sub
Any ideas anyone?
I'm getting some weird behaviour trapping events within a collection class.
The basic structure is
1. A form with 4 TextBoxes.
2. Each TextBox is referenced WithEvents in a class called clsKey.
3. The referenced TextBox.OnFocus Event is used to raise an event called ActivateKey, which has clsKey.Me as the parameter.
4. Each clsKey is referenced WithEvents in the collection object of a class called clsKeys.
Now here's the thing. When any of the TextBoxes get the TextBox.OnFocus event raises the ActivateKey event. However, this event is only trapped in clsKeys if the TextBox is not null.
Here's the code:
|Class clsKey|
Private WithEvents ctlTextBox As TextBox
Public Event ActivateKey(ByVal ActiveKey As clsKey)
Private Sub ctlTextBox_GotFocus()
RaiseEvent ActivateKey(Me)
End Sub
|Class clsKeys|
Private WithEvents objKey As clsKey
Private objActiveKey As clsKey
Private Sub objKey_ActivateKey(ByVal ActiveKey As clsKey)
Set objActiveKey = ActiveKey
End Sub
Any ideas anyone?