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 pressed

MyInputBox = dlgvar.Text1

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

End If

End Function

This script creates the dialog displayed above.

To perform processing while a user dialog is active, define a special "dialog function." The dialog function will be 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 will be 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 theHelp | BASIC Language Helpfor more information about how to process dialog events in a dialog function.

See Also

Getting User Input

Creating Dialogs with Scripter

Introducing Scripter

Object Hierarchy

Surfer Object Model