Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To run the exit event for the TextBox control, put the focus back onto a different control within the Frame. To do this, use the
SetFocus method of any other control inside the Frame.
The macro example below illustrates how to run an exit event for TextBox1 when TextBox1 is within a Frame, and CommandButton1 is outside the Frame. When TextBox1 has the focus and you click
CommandButton1, the exit event for the TextBox runs before the message box in CommandButton1_Click appears. If you do not shift the focus to Frame1, the exit event for TextBox1 runs after the message box for CommandButton1_Click appears.
This example assumes a UserForm that contains a Frame control, two TextBox controls inside the Frame, and a CommandButton control outside the Frame.
Private Sub CommandButton1_Click()
TextBox2.SetFocus
MsgBox "Button Click"
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Box 1 exit"
End Sub