UserDialog Example

The following function demonstrates how to define, display, and extract the values entered in a user dialog.

 Function MyInputBox As String

'Define the dialog template. This definition

'is inserted by the UserDialog editor.

 Begin Dialog UserDialog 250,112,"Caption"

 TextBox 10,14,230,28,.Text1

 CheckBox 20,49,160,14,"Check Box",.Check1

 OKButton 20,77,90,21

 CancelButton 130,77,90,21

 End Dialog

 

'Declare a dialog variable

 Dim dlgvar As UserDialog

 

'Initialize the dialog controls

 dlgvar.Text1 = "This is the initial text to display"

 dlgvar.Check1 = True ' start with check box checked

 

'Display the dialog and wait for the OK or Cancel

'button to be pressed

 result = Dialog(dlgvar)

 

'Extract the information entered into the dialog

 If result = -1 Then ' check to see if OK button was clicked

 MyInputBox = dlgvar.Text1

 If dlgvar.Check1 Then Debug.Print "The Check Box was Checked!"

 End If

 End Function

To perform processing while a user dialog is active, define a special "dialog function." The dialog function is called when various dialog events occur. To define a dialog function:

  1. While designing the dialog, double-click in a blank portion of the dialog design area to activate the Edit UserDialog Properties dialog.

  2. Enter a name for the Dialog Function property of the dialog. This property gives the name of a function that is called when dialog events occur.

  3. When you save the dialog, Scripter asks you if it should create a skeleton dialog function. Click the Yes button, and Scripter inserts the basic instructions for a dialog function into your script.

Refer to the DialogFunc help topic in the Help | BASIC Language Help for more information about how to process dialog events in a dialog function.

See Also

Creating Dialog Boxes

UserDialog Items

Getting User Input

Scripter BASIC Language

Object Hierarchy

Object List