VERSION 5.00 Begin VB.Form Contacts Caption = "Contacts" ClientHeight = 4575 ClientLeft = 1470 ClientTop = 1725 ClientWidth = 7140 BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" LockControls = -1 'True PaletteMode = 1 'UseZOrder ScaleHeight = 305 ScaleMode = 3 'Pixel ScaleWidth = 476 Begin VB.TextBox txtName BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 240 TabIndex = 0 Top = 1680 Width = 2535 End Begin VB.TextBox txtEmail BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4320 TabIndex = 1 Top = 1680 Width = 2535 End Begin VB.TextBox txtTotalEntries Height = 285 Left = 6240 TabIndex = 3 Top = 4080 Width = 615 End Begin VB.CommandButton cmdClear Caption = "Clear All" Height = 495 Left = 2880 TabIndex = 6 Top = 3960 Width = 975 End Begin VB.CommandButton cmdDelete Caption = "Delete" Enabled = 0 'False Height = 495 Left = 1560 TabIndex = 5 Top = 3960 Width = 975 End Begin VB.CommandButton cmdAdd Caption = "Add" Default = -1 'True Height = 495 Left = 240 TabIndex = 4 Top = 3960 Width = 975 End Begin VB.ListBox lstEntries BeginProperty Font Name = "Times New Roman" Size = 15.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = -1 'True Strikethrough = 0 'False EndProperty ForeColor = &H00FF0000& Height = 1500 ItemData = "Contacts.frx":000C Left = 240 List = "Contacts.frx":000E TabIndex = 2 Top = 2160 Width = 6615 End Begin VB.Line Line1 X1 = 16 X2 = 456 Y1 = 8 Y2 = 8 End Begin VB.Line Line2 BorderColor = &H00000000& X1 = 16 X2 = 456 Y1 = 72 Y2 = 72 End Begin VB.Label lblEntries Caption = "# of contacts:" Height = 255 Left = 4680 TabIndex = 10 Top = 4080 Width = 1455 End Begin VB.Label lblEmail Caption = "Email Address:" Height = 255 Left = 4320 TabIndex = 9 Top = 1320 Width = 1575 End Begin VB.Label lblName Caption = "Name:" Height = 255 Left = 240 TabIndex = 8 Top = 1320 Width = 975 End Begin VB.Label Label1 Alignment = 2 'Center Caption = "Contact List" BeginProperty Font Name = "MS Sans Serif" Size = 24 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 240 TabIndex = 7 Top = 360 Width = 6615 End End Attribute VB_Name = "Contacts" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub cmdAdd_Click() Dim szEntry As String 'Get name and number szEntry = txtName.Text + " --- " + txtEmail.Text 'Add name to list box lstEntries.AddItem szEntry 'Reset entry fields, number of entries, "Delete" button txtEmail.Text = "" txtName.Text = "" txtName.SetFocus txtTotalEntries.Text = Str(lstEntries.ListCount) cmdDelete.Enabled = True End Sub Private Sub cmdClear_Click() 'Clear all entries from list box lstEntries.Clear 'Disable "Delete" command button cmdDelete.Enabled = False 'Show the number of items in "lstEntries" list box txtTotalEntries.Text = Str(lstEntries.ListCount) 'Reset focus to name textbox txtName.SetFocus End Sub Private Sub cmdDelete_Click() Dim nIndex As Integer If (lstEntries.ListIndex <> -1) Then 'Get the index of selected item nIndex = lstEntries.ListIndex 'Remove the selected item lstEntries.RemoveItem nIndex 'Show the number of items in "lstEntries" list box txtTotalEntries.Text = Str(lstEntries.ListCount) 'If "lstEntries" is empty, disable "Delete" button If (lstEntries.ListCount = 0) Then cmdDelete.Enabled = False End If End If End Sub Private Sub Form_Activate() txtName.SetFocus txtTotalEntries.Locked = True txtName.Text = "John Doe" txtEmail.Text = "johndoe@anywhere.com" End Sub Private Sub lstEntries_Click() 'Disable "Delete" command button If (lstEntries.ListIndex = -1) Then cmdDelete.Enabled = False End If End Sub