SetFocus

Moves the focus to the specified control or form.

Syntax

object.SetFocus

The object placeholder represents an object expression that evaluates to an object.

Remarks

The object must be a Form object, or control that can receive the focus. After invoking the SetFocus method, any user input is directed to the specified form or control.

You can only move the focus to a visible form or control. Because a form and controls on a form are not visible until the form's Load event has finished, you cannot use the SetFocus method to move the focus to the form being loaded in its own Load event unless you first use the Show method to show the form before the Form_Load event procedure is finished.

You also cannot move the focus to a form or control if the Enabled property is set to False. If the Enabled property has been set to False at design time, you must first set it to True before it can receive the focus using the SetFocus method.