Visual Basic Reference
Occurs when an object receives the focus, either by user action, such as tabbing to or clicking the object, or by changing the focus in code using the SetFocus method. A form receives the focus only when all visible controls are disabled.
Private Sub Form_GotFocus( )
Private Sub object_GotFocus([index As Integer])
The GotFocus event syntax has these parts:
|object||An object expression that evaluates to an object in the Applies To list.|
|index||An integer that uniquely identifies a control if it's in a control array.|
Typically, you use a GotFocus event procedure to specify the actions that occur when a control or form first receives the focus. For example, by attaching a GotFocus event procedure to each control on a form, you can guide the user by displaying brief instructions or status bar messages. You can also provide visual cues by enabling, disabling, or showing other controls that depend on the control that has the focus.
Note An object can receive the focus only if its Enabled and Visible properties are set to True. To customize the keyboard interface in Visual Basic for moving the focus, set the tab order or specify access keys for controls on a form.