DlgValue (function)


DlgValue(ControlName$ | ControlIndex)


Returns an Integer indicating the value of the specified control.


The value of any given control depends on its type, according to the following table:


Control Type

DlgValue Returns


Option group

The index of the selected option button within the group (0 is the first option button, 1 is the second, and so on).


List box

The index of the selected item.


Drop list box

The index of the selected item.


Check box

1 if the check box is checked; 0 otherwise.


A runtime error is generated if DlgValue is used with controls other than those listed in the above table.

The ControlName$ parameter contains the name of the .Identifier parameter associated with a control in the dialog box template. Alternatively, by specifying the ControlIndex parameter, a control can be referred to using its index in the dialog box template (0 is the first control in the template, 1 is the second, and so on).


This code fragment toggles the value of a check box.

Sub Main()

  If DlgValue("MyCheckBox") = 1 Then
    DlgValue "MyCheckBox",0
    DlgValue "MyCheckBox",1
  End If
End Sub

See Also

DlgControlId (function); DlgEnable (function); DlgEnable (statement); DlgFocus (function); DlgFocus (statement); DlgListBoxArray (function); DlgListBoxArray (statement); DlgSetPicture (statement); DlgText (statement); DlgText$ (function); DlgValue (statement); DlgVisible (statement); DlgVisible (function).

More information