home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmListBox
- Caption = "List Box Example"
- Height = 5730
- Left = 1170
- LinkTopic = "Form1"
- ScaleHeight = 5325
- ScaleWidth = 5625
- Top = 1320
- Width = 5745
- Begin CommandButton cmdClose
- Caption = "&Close"
- Height = 495
- Left = 3840
- TabIndex = 8
- Top = 3840
- Width = 1215
- End
- Begin CommandButton cmdClear
- Caption = "C&lear"
- Height = 495
- Left = 3840
- TabIndex = 7
- Top = 2520
- Width = 1215
- End
- Begin CommandButton cmdRemove
- Caption = "&Remove"
- Enabled = 0 'False
- Height = 495
- Left = 3840
- TabIndex = 6
- Top = 1680
- Width = 1215
- End
- Begin CommandButton cmdAdd
- Caption = "&Add"
- Default = -1 'True
- Enabled = 0 'False
- Height = 495
- Left = 3840
- TabIndex = 5
- Top = 840
- Width = 1215
- End
- Begin ListBox lstClient
- Height = 2760
- Left = 600
- Sorted = -1 'True
- TabIndex = 1
- Top = 1440
- Width = 2655
- End
- Begin TextBox txtName
- Height = 375
- Left = 600
- TabIndex = 0
- Top = 720
- Width = 2655
- End
- Begin Label lblDisplay
- BorderStyle = 1 'Fixed Single
- Height = 375
- Left = 2400
- TabIndex = 4
- Top = 4440
- Width = 855
- End
- Begin Label lblClients
- Caption = "# Clients"
- Height = 255
- Left = 600
- TabIndex = 3
- Top = 4440
- Width = 855
- End
- Begin Label lblName
- Caption = "&Name to add"
- Height = 255
- Left = 600
- TabIndex = 2
- Top = 360
- Width = 1215
- End
- Sub cmdAdd_Click ()
- lstClient.AddItem txtName.Text ' Add client name to list box.
- txtName.Text = "" ' Clear text box.
- txtName.SetFocus ' Place focus back in text box.
- lblDisplay.Caption = lstClient.ListCount ' Display number of entries in list.
- End Sub
- Sub cmdClear_Click ()
- lstClient.Clear ' Empty list.
- cmdRemove.Enabled = False ' Disable Remove button.
- lblDisplay.Caption = lstClient.ListCount ' Display number of items in list.
- End Sub
- Sub cmdClose_Click ()
- Unload Me ' Unload this form.
- End Sub
- Sub cmdRemove_Click ()
- Dim Ind As Integer
- Ind = lstClient.ListIndex ' Get index.
- If Ind >= 0 Then ' Make sure list item is selected.
- lstClient.RemoveItem Ind ' Remove it from list box.
- lblDisplay.Caption = lstClient.ListCount ' Display number of items in list.
- Else
- Beep ' Should never occur, because Remove is always disabled if no entry is selected.
- End If
- ' Disable button if no entries selected in list.
- cmdRemove.Enabled = (lstClient.ListIndex <> -1)
- End Sub
- Sub lstClient_Click ()
- cmdRemove.Enabled = (lstClient.ListIndex <> -1)
- End Sub
- Sub lstClient_DblClick ()
- ' Press Remove button
- cmdRemove.Value = True
- End Sub
- Sub txtName_Change ()
- ' Enable Add button if at least one character in name
- cmdAdd.Enabled = (Len(txtName.Text) > 0)
- End Sub
-