Microsoft KB Archive/62164

Providing a (Blank) Choice in WordBASIC ListBoxes

PSS ID Number: Q62164 Article last modified on 06- 7-1991

1.00 MS-DOS

Summary: In a WordBASIC ListBox or ComboBox, a good programming technique is to allow for a “no choice” or (Blank) choice. The advantages of this are as follows: 1. You have the option of having no default for the ListBox. 2. Once an item is selected from the ListBox, users of your program will have the option of changing their minds and choosing another choice from the list or the “no choice” item. An example of the utility of this feature is where your dialog box returns variables to be used as inputs for records in a database. Since it is feasible to have blank fields in a record, it is friendly programming to provide for this in your WordBASIC ListBoxes and ComboBoxes.

More Information: You can provide a blank choice in a ListBox or ComboBox by employing the following two methods: 1. Declare the Array_Variable$ to be one larger than the number of values you are going to assign to the variable. The following is an example: Dim Product$(4) {Declares Array_Variable$ of size 4) . . . Product$(0) = "soap" {Assigns 3 values to Array_Variable$ ) Product$(1) = "milk"  Product$ (2) = “bread” {4th value in array will be blank) When the Array_Variable$ is used for a ListBox or ComboBox, the resulting ListBox will have a (Blank) choice as the last choice in the list. 2. Declare the Array_Variable$ to be of the same size as the number of values you will assign, but assign one blank value, as follows: Dim Product$(3) {Declares Array_Variable$  of size 3). . . Product$(0) = "soap" {Assigns 3 values to Array_Variable$ ) Product$(1) = "milk" Product$ (2) = &quot;&quot; {3rd value in array will be blank) When the Array_Variable$ is used for a ListBox or ComboBox, the resulting ListBox will have a (Blank) choice as the last choice in the list. Note: For a description of variable declarations and array variables, see the “Data Types” Section on Pages 9-10 in the “Introduction” section of the “Microsoft Word for Windows Technical Reference.” For a description of using array variables for ListBoxes and ComboBoxes, see “ListBox” and “ComboBox” in the “Dialog Control Definition Statements” section on Pages 107-109 of the “Microsoft Word for Windows Technical Reference.”

Additional reference words: w4wmacro