SelectBox (function)

Syntax SelectBox(title,prompt,ArrayOfItems)
Description Displays a dialog box that allows the user to select from a list of choices and returns an Integer containing the index of the item that was selected.
Comments The SelectBox statement accepts the following parameters:
Parameter Description
title Title of the dialog box. This can be an expression convertible to a String. A runtime error is generated if title is Null.
prompt Text to appear immediately above the list box containing the items. This can be an expression convertible to a String. A runtime error is generated if prompt is Null.
ArrayOfItems Single-dimensioned array. Each item from the array will occupy a single entry in the list box. A runtime error is generated if ArrayOfItems is not a single-dimensioned array. ArrayOfItems can specify an array of any fundamental data type (structures are not allowed). Null and Empty values are treated as zero-length strings.
The value returned is an Integer representing the index of the item in the list box that was selected, with 0 being the first item. If the user selects Cancel, –1 is returned.
result% = SelectBox("Picker","Pick an application:",a$)
Example This example gets the current apps running, puts them in to an array and then asks the user to select one from a list.
Sub Main()
  Dim a$()
  AppList a$
  result% = SelectBox("Picker","Pick an application:",a$)
  If Not result% = -1 then
    Msgbox "User selected: " & a$(result%)
  Else
    Msgbox "User canceled"
  End If
End Sub
See Also MsgBox (statement); AskBox$ (function); AskPassword$ (function); InputBox, InputBox$ (functions); OpenFilename$ (function); SaveFilename$ (function); AnswerBox (function)
Note The SelectBox displays all text in its dialog box in 8-point MS Sans Serif.