ComboBox (statement)

Syntax

ComboBox X,Y,width,height,ArrayVariable,.Identifier

Description

This statement defines a combo box within a dialog box template.

Comments

When the dialog box is invoked, the combo box will be filled with the elements from the specified array variable.

This statement can only appear within a dialog box template (i.e., between the Begin Dialog and End Dialog statements).

The ComboBox statement requires the following parameters:

 

Parameter

Description

 

X, Y

Integer coordinates specifying the position of the control (in dialog units) relative to the upper left corner of the dialog box.

 

width, height

Integer coordinates specifying the dimensions of the control in dialog units.

 

ArrayVariable

Single-dimensioned array used to initialize the elements of the combo box. If this array has no dimensions, then the combo box will be initialized with no elements. A runtime error results if the specified array contains more than one dimension.

ArrayVariable can specify an array of any fundamental data type (structures are not allowed). Null and Empty values are treated as zero-length strings.

 

Identifier

Name by which this control can be referenced by statements in a dialog function (such as DlgFocus and DlgEnable). This parameter also creates a string variable whose value corresponds to the content of the edit field of the combo box. This variable can be accessed using the syntax:

DialogVariable.Identifier

 

When the dialog box is invoked, the elements from ArrayVariable are placed into the combo box. The .Identifier variable defines the initial content of the edit field of the combo box. When the dialog box is dismissed, the .Identifier variable is updated to contain the current value of the edit field.

Example

This example creates a dialog box that allows the user to select a day of the week.

Sub Main()

  Dim days$(6)
  days$(0) = "Monday"
  days$(1) = "Tuesday"
  days$(2) = "Wednesday"
  days$(3) = "Thursday"
  days$(4) = "Friday"
  days$(5) = "Saturday"
  days$(6) = "Sunday"

  Begin Dialog DaysDialogTemplate 16,32,124,96,"Days"
    OKButton 76,8,40,14,.OK
    Text 8,10,39,8,"&Weekdays:"
    ComboBox 8,20,60,72,days$,.Days
  End Dialog
  Dim DaysDialog As DaysDialogTemplate
  DaysDialog.Days = Format(Now,"dddd") 'Set to today.
  r% = Dialog(DaysDialog)
  MsgBox "You selected: " & DaysDialog.Days
End Sub

See Also

CancelButton (statement); CheckBox (statement); Dialog (function); Dialog (statement); DropListBox (statement); GroupBox (statement); ListBox (statement); OKButton (statement); OptionButton (statement); OptionGroup (statement); Picture (statement); PushButton (statement); Text (statement); TextBox (statement); Begin Dialog (statement), PictureButton (statement).

More information

C