DlgText, DlgText$()

Syntax

DlgText Identifier[$], Text$

DlgText$(Identifier[$])

Remarks

The DlgText statement is used in a dialog function to set the text or label for the dialog box control identified by Identifier[$]. The DlgText statement does not change the string identifier of a dialog box control.

For a text box or combo box, DlgText sets the text within the text box. For dialog box controls that have labels, such as check boxes, option buttons, option groups, and command buttons, DlgText sets the label. For list boxes, DlgText sets the selection to Text$ or to the first item that begins with Text$.

For information about using a dialog function, see Chapter 5, "Working with Custom Dialog Boxes," in Part 1, "Learning WordBasic."

Argument

Explanation

Identifier[$]

The string or numeric identifier of the dialog box control

Text$

The text or label to set


The DlgText$() function returns the text or label of the dialog box control identified by Identifier[$]. If the dialog box control is a list box, the text of the selected item is returned. If the dialog box control is a text box or combo box, DlgText$() returns the text that appears in the text box.

Example

This example hides and displays a control in a dialog box, and, accordingly, toggles the label of a command button between "Hide Control" and "Show Control." (The main subroutine that contains the dialog box definition is not shown.) By default, a custom dialog box is closed when the user chooses a command button; however, in this example, the keepDisplayed = 1 and dlgTest = keepDisplayed instructions keep the dialog box displayed (when a dialog function returns a value of 1, the dialog box remains displayed).


Function dlgTest(identifier$, action, suppvalue)
Select Case action
Case 1                        'The dialog box is displayed
Case 2                        'The user chooses a button
If identifier$ = "Hide" Then
    If DlgText$("Hide") = "Hide &Control" Then
        DlgVisible "Option1", 0
        DlgText$ "Hide", "Show &Control"
    Else
        DlgVisible "Option1", 1
        DlgText$ "Hide", "Hide &Control"
    End If
    keepDisplayed = 1
End If
Case 3                        'Text change (not applicable)
Case Else
End Select
dlgTest = keepDisplayed
End Function

See Also

DlgValue