DlgValue Instruction/Function

Syntax
DlgValue DlgItem, Value
-or-
DlgValue(DlgItem)
Group
Dialog Function
Description
Instruction: Set the numeric values for DlgItem.

Function: Return the numeric values for DlgItem. (A MultiListBox user dialog item returns an array.)

This instruction/function must be called directly or indirectly from a dialogfunc. The DlgItem should refer to a CheckBox, ComboBox, DropListBox, ListBox, MultiListBox or OptionGroup.
Parameters Description
DlgItem If this is a numeric value then it is the dialog item number. The first item is 0, second is 1, etc. If this is a string value then it is the dialog item's field name.
Value Set the text of DlgItem to this numeric value. (A MultiListBox user dialog item uses an array.)

Sub Main
    Begin Dialog UserDialog 150,147,.DialogFunc
        GroupBox 10,7,130,77,"Direction",.Field1
        PushButton 100,28,30,21,"&Up"
        PushButton 100,56,30,21,"&Dn"
        OptionGroup .Direction
            OptionButton 20,21,80,14,"&North",.North
            OptionButton 20,35,80,14,"&South",.South
            OptionButton 20,49,80,14,"&East",.East
            OptionButton 20,63,80,14,"&West",.West
        OKButton 10,91,130,21
        CancelButton 10,119,130,21
    End Dialog
    Dim dlg As UserDialog
    Dialog dlg
    MsgBox "Direction=" & dlg.Direction
End Sub
 
Function DialogFunc(DlgItem$, Action%, SuppValue?) As Boolean
    Select Case Action%
    Case 1 ' Dialog box initialization
        Beep
    Case 2 ' Value changing or button pressed
        Select Case DlgItem$
        Case "Up"
            DlgValue "Direction",0
            DialogFunc = True 'do not exit the dialog
        Case "Dn"
            DlgValue "Direction",1
            DialogFunc = True 'do not exit the dialog
        End Select
    End Select
End Function