ListCount Property

See Also1WR4IPL                 ExampleN5COSN>Low

Applies To

Combo box1YZXFF6, directory list boxO9U5A0, drive list box5WJO0PW, file list box1M6S8UX, list boxG11UCK.

Description

Specifies the number of items in the list portion of a control; not available at design time and read-only at run time.

Usage

[form.]control.ListCount

Remarks

ListCount provides specific information for each control:

         Combo box and list boxthe number of items in the list.

         Directory list boxthe number of subdirectories in the current directory.

         Drive list boxthe number of drive connections.

         File list boxthe number of files in the current directory that match the PatternXYKZRG property.

 

If no item is selected, the ListIndex property value is -1.  The first item in the list is ListIndex 0, and ListCount is always one more than the largest ListIndex value.

Data Type

IntegerDOKXHY


See Also

Help:

AddItem Method2BIX3OB

List PropertyBKCX6E

ListIndex Property4K7KHR

RemoveItem MethodM867OS

 

Programmer's Guide:

Chapter 3, "Creating and Using Controls"


ListCount Property Example

The example loads a list of your printer fonts into a combo box, displays the first item in the list, and prints the total number of fonts.  Each click of the button changes all items in the list to uppercase or lowercase.  To try this example, paste the code into the Declarations section of a form that contains a combo box (Style = 2) and a command button.  Then press F5 and click the command button.

Sub Form_Load ()
  Dim I                                  ' Declare variable.
  AutoRedraw = True                      ' Set AutoRedraw.
  For I = 0 To Printer.FontCount - 1     ' Put font names in list.
    Combo1.AddItem Printer.Fonts(I)
  Next I
  Combo1.ListIndex = 0                   ' Set text to first item.
  ' Print ListCount info on form.
  Print "Number of Printer fonts: "; Combo1.ListCount
End Sub
Sub Command1_Click ()
  Static UpperCase
  Dim I                                  ' Declare variable
  For I = 0 To Combo1.ListCount - 1      ' Loop through list.
    If UpperCase Then
      Combo1.List(I) = UCase(Combo1.List(I))
    Else
      Combo1.List(I) = LCase(Combo1.List(I))
    End If
  Next I
  UpperCase = Not UpperCase              ' Change case.
End Sub