home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmListBox
- Caption = "List Box Example"
- ClientHeight = 5310
- ClientLeft = 1230
- ClientTop = 1695
- ClientWidth = 5655
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 1
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 5715
- Left = 1170
- LinkTopic = "Form1"
- ScaleHeight = 5310
- ScaleWidth = 5655
- Top = 1350
- Width = 5775
- Begin VB.CommandButton cmdClose
- Caption = "&Close"
- Height = 495
- Left = 3840
- TabIndex = 8
- Top = 3840
- Width = 1215
- End
- Begin VB.CommandButton cmdClear
- Caption = "C&lear"
- Height = 495
- Left = 3840
- TabIndex = 7
- Top = 2520
- Width = 1215
- End
- Begin VB.CommandButton cmdRemove
- Caption = "&Remove"
- Enabled = 0 'False
- Height = 495
- Left = 3840
- TabIndex = 6
- Top = 1680
- Width = 1215
- End
- Begin VB.CommandButton cmdAdd
- Caption = "&Add"
- Default = -1 'True
- Enabled = 0 'False
- Height = 495
- Left = 3840
- TabIndex = 5
- Top = 840
- Width = 1215
- End
- Begin VB.ListBox lstClient
- Height = 2760
- Left = 600
- Sorted = -1 'True
- TabIndex = 1
- Top = 1440
- Width = 2655
- End
- Begin VB.TextBox txtName
- Height = 375
- Left = 600
- TabIndex = 0
- Top = 720
- Width = 2655
- End
- Begin VB.Label lblDisplay
- BorderStyle = 1 'Fixed Single
- Height = 375
- Left = 2415
- TabIndex = 4
- Top = 4440
- Width = 855
- End
- Begin VB.Label lblClients
- Caption = "# Clients"
- Height = 255
- Left = 600
- TabIndex = 3
- Top = 4440
- Width = 855
- End
- Begin VB.Label lblName
- Caption = "&Name to add"
- Height = 255
- Left = 600
- TabIndex = 2
- Top = 360
- Width = 1215
- End
- Attribute VB_Name = "frmListBox"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub cmdAdd_Click()
- lstClient.AddItem txtName.Text ' Add a client name to the list box.
- txtName.Text = "" ' Clear the text box.
- txtName.SetFocus ' Place focus back to the text box.
- lblDisplay.Caption = lstClient.ListCount ' Display the number of items in the list box.
- End Sub
- Private Sub cmdClear_Click()
- lstClient.Clear ' Empty the list box.
- cmdRemove.Enabled = False ' Disable the Remove button.
- lblDisplay.Caption = lstClient.ListCount ' Display the number of items in the list box.
- End Sub
- Private Sub cmdClose_Click()
- Unload Me ' Unload this form.
- End Sub
- Private Sub cmdRemove_Click()
- Dim Ind As Integer
- Ind = lstClient.ListIndex ' Get index.
- If Ind >= 0 Then ' Make sure a list item is selected.
- lstClient.RemoveItem Ind ' Remove the item from the list box.
- lblDisplay.Caption = lstClient.ListCount ' Display the number of items in the list box.
- Else
- Beep ' This should never occur, because Remove is always disabled if no entry is selected.
- End If
- ' Disable the Remove button if no entries are selected in the list box.
- cmdRemove.Enabled = (lstClient.ListIndex <> -1)
- End Sub
- Private Sub lstClient_Click()
- cmdRemove.Enabled = (lstClient.ListIndex <> -1)
- End Sub
- Private Sub lstClient_DblClick()
- ' A user clicked the Remove button.
- cmdRemove.Value = True
- End Sub
- Private Sub txtName_Change()
- ' Enable the Add button if at least one character in the name is entered or changed.
- cmdAdd.Enabled = (Len(txtName.Text) > 0)
- End Sub
-