GetListBoxCount method (WinStudio scripts)
Applies To
IWSFormComponent interface, List component type objects
Definition
Returns the number of list items in a list box (List component type). Read-only.
Syntax
object.GetListBoxCount( )
| Part | Description | 
| object | Required. A reference to a List component type object. | 
Remarks
The return value is an integer indicating the number of items in the list.
Note:  This method does not work with other list source components, such
		  as drop-down lists, combo boxes, or grid columns.
		
 
	     Example
Sub Main()
   Dim oListBox As IWSFormComponent
   Dim iCurrentRow As Integer
   Dim iCounter As Integer
   Dim strListBox As String
   Dim bSuccess As Boolean
   Dim iReturn As Integer
   Dim iRow As Integer
   oListBox = ThisForm.Components("list1")
   'Check to verify that a list item is selected.
   'If not, display a message and exit. 
   iCurrentRow = oListBox.GetListBoxCurSel
   If iCurrentRow = -1 Then
      Application.ShowMessage("No list item selected!")
      Exit Sub
   End If
   'Display list box properties.
   Application.ShowMessage("Number of items: " & oListBox.GetListBoxCount().ToString() _
      & vbLf & "Current selection: " & (iCurrentRow + 1).ToString() & vbLf & _
      "Text: " & oListBox.GetListBoxText(iCurrentRow))
   'Display contents of list box.
   strListBox = ""
   For iCounter = 0 To oListBox.GetListBoxCount() - 1
      strListBox = strListBox & (iCounter + 1).ToString() & "  " & _
         oListBox.GetListBoxText(iCounter) & vbLf
   Next iCounter
   Application.ShowMessage("The following are the currently defined events:" _
      & vbLf & strListBox)
   'Set list box to second entry.
   iRow = 1
   bSuccess = oListBox.SetListBoxCurSel(iRow)
   'Insert new items at the second position.
   iReturn = oListBox.InsertListBoxString(iRow, "New Row Entry 1")
   iReturn = oListBox.InsertListBoxString(iRow, "New Row Entry 2")
   'Display contents of list box.
   strListBox = ""
   For iCounter = 0 To oListBox.GetListBoxCount() - 1
      strListBox = strListBox & (iCounter + 1).ToString() & "  " & _
         oListBox.GetListBoxText(iCounter) & vbLf
   Next iCounter
   Application.ShowMessage("Current list: " & vbLf & strListBox)
   'Delete the rows just added.
   oListBox.DeleteListBoxString(iRow + 1)
   oListBox.DeleteListBoxString(iRow)
   'Display contents of list box.
   strListBox = ""
   For iCounter = 0 To oListBox.GetListBoxCount() - 1
      strListBox = strListBox & (iCounter + 1).ToString() & "  " & _
         oListBox.GetListBoxText(iCounter) & vbLf
   Next iCounter
   Application.ShowMessage("Current list: " & vbLf & strListBox)
End Sub