G
Gary Mc
I am trying to create runtime text fields and then capture events on this
text field. I have experimented with several things I have found on the
internet, but have been unsuccessful. The form shows when I run it and the
text box appears, but when I click in it, I do not invoke the control event.
Any ideas?
I have a class module: MyCtrlEvents
******
Option Explicit
Public WithEvents MyBox As MSForms.TextBox
Private Sub MyBox_Click()
MsgBox MyBox.Name & " click!"
End Sub
******
And I have a form with nothing on it. Here is the code.
******
Dim c() As MyCtrlEvents
Private Sub UserForm_Activate()
ReDim c(1)
Set c(0) = New MyCtrlEvents
Set c(0).MyBox = Me.Controls.Add("Forms.Textbox.1")
With c(0).MyBox
.Name = "TextBoxTest"
.Top = 42
.Width = 72
.Height = 18
.Left = 20
End With
End Sub
*****
text field. I have experimented with several things I have found on the
internet, but have been unsuccessful. The form shows when I run it and the
text box appears, but when I click in it, I do not invoke the control event.
Any ideas?
I have a class module: MyCtrlEvents
******
Option Explicit
Public WithEvents MyBox As MSForms.TextBox
Private Sub MyBox_Click()
MsgBox MyBox.Name & " click!"
End Sub
******
And I have a form with nothing on it. Here is the code.
******
Dim c() As MyCtrlEvents
Private Sub UserForm_Activate()
ReDim c(1)
Set c(0) = New MyCtrlEvents
Set c(0).MyBox = Me.Controls.Add("Forms.Textbox.1")
With c(0).MyBox
.Name = "TextBoxTest"
.Top = 42
.Width = 72
.Height = 18
.Left = 20
End With
End Sub
*****