FocusControl Property

Property that allows you to get or set which control will receive the focus when the dialog box is displayed. When this property is an empty string, the first control in the dialog box will be focused.

object.FocusControl = caption_or_name
existing_value
= object.FocusControl

Arguments

object

Required.  A variable containing a dialog object created by calling CreateObject or new ActiveXControl.

caption_or_name

Required. If the control to be focused is a push button, this value should be the caption of the button that should receive focus. If the control to be focused is a different type of control, this value should be the name that you gave the control when you added it to the dialog box.

existing_value

A variable to receive the caption of the button or the name of the control that will be focused when the dialog box is displayed.

Remarks
Assign the desired value to FocusControl after the control is added to the dialog box and before the dialog box is executed. Setting FocusControl after the dialog box is already showing has no immediate effect, although it may have some effect if the dialog is hidden and displayed again.

Example

Sub main
  ' Create the dialog box
  Set Dialog = CreateObject("TPFSoftware.ScriptDialog")


  ' Add a text field
  Dialog.AddTextField "ID", "User:", 15, "frank"
  ' Add a password field
  Dialog.AddPasswordField "Pswd", "Password:", 15
  ' Add a row of buttons
  Dialog.AddButtons "button", Array("OK", "Cancel")
  ' Arrange to give focus to the second text field
  Dialog.FocusControl = "Pswd"
  ' Display the dialog box
  Set Result = Dialog.Execute End Sub