Dim
LastControl
As
MSForms.Control
Dim
tbxcoll
As
New
Collection
Private
Sub
CommandButton1_Click()
CheckForExit
End
Sub
Private
Sub
CommandButton1_KeyUp(
ByVal
KeyCode
As
MSForms.ReturnInteger,
ByVal
Shift
As
Integer
)
CheckForExit
End
Sub
Private
Sub
UserForm_Activate()
CheckForExit
End
Sub
Private
Sub
UserForm_Initialize()
Dim
txt
As
MSForms.TextBox
Dim
i
As
Integer
For
i = 1
To
2
Set
txt =
Me
.Controls.Add(
"Forms.TextBox.1"
,
"TxtKanalEckig"
& i,
True
)
With
txt
.Left = 10
.Top = 30 * i
.Width = 100
.Height = 20
.Text =
"TextBox "
& i
.Tag =
"TextBox"
& i
End
With
tbxcoll.Add
New
myTextbox
Set
tbxcoll(tbxcoll.Count).tbx = txt
Next
i
End
Sub
Public
Sub
CheckForExit()
If
Not
LastControl
Is
Nothing
Then
If
LastControl.Name <>
Me
.ActiveControl.Name
Then
MsgBox LastControl.Name &
" wurde verlassen"
End
If
Set
LastControl =
Me
.ActiveControl
End
Sub