Microsoft KB Archive/101552

{|
 * width="100%"|

Blank Item Appears in Dialog ListBox or ComboBox

 * }

Q101552

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c

-

SUMMARY
A Microsoft WordBasic ListBox or ComboBox control may contain a blank selection if the array variable assignment does not begin at 0 (zero) or if the array variable is dimensioned with more elements than needed.

MORE INFORMATION
An array variable gives a single name to a group of related values and organizes them in a list or table.

"Dim ArrayVariableName(LastElementNumber)" The first element of a WordBasic array is always numbered 0 (zero). This means that the number of the last element is one less than the number of elements. For example:

  Dim Months$(11)      'Define an array with 12 elements Before you display a dialog box containing a list or combo box, you must define an array and fill it with the items to be listed. For example:

  Sub Main Dim FourWinds$(3)  'Define an array with 4 elements FourWinds$(0) = "East" FourWinds$(1) = "West" FourWinds$(2) = "North" FourWinds$(3) = "South" Begin Dialog UserDialog 320, 144, "Microsoft Word" OKButton 207, 92, 88, 21 CancelButton 207, 116, 88, 21 ListBox 21, 9, 169, 96, FourWinds$, .Listbox1 End Dialog Dim dlg As UserDialog n = Dialog(dlg) End Sub If a value is not assigned to the first array element, FourWinds$(0), a blank selection will appear at the top of the list box. If a blank selection appears at the bottom of the list box, the number of array elements is NOT one less than the total number of elements.

  Dim FourWinds$(3)   'Define an array with 4 elements