Listbox techniques - Thursday, July 11th, 2002
Simpler, July 10th example and
email note. This version uses a ListBox with only row #0 having the
summary line. This is the ONE ROW Summary version.
' TWO ROW summary version...
' Modified after class on July 11th, 2002 to help students
' with the Project #2, page 199 assignment issues and
' techniques.
' Illustrates having the first TWO items in the listbox
' be the summary of total count and total sum so far.....
' Compare this to the July 10th version...
Dim n As Integer
Dim totalDollars As Currency
Private Sub cmdAdd_Click()
lstDemo.AddItem txtName & " " & Format(txtSaleAmount, "Currency"), 2
n = n + 1
totalDollars = totalDollars + CCur(txtSaleAmount)
lstDemo.RemoveItem 0
lstDemo.RemoveItem 0
lstDemo.AddItem "Sales today: " & Format(totalDollars, "Currency"), 0
lstDemo.AddItem "Customers today: " & n, 0
cmdClear_Click
End Sub
Private Sub cmdClear_Click()
txtSaleAmount = ""
txtName = ""
txtName.SetFocus
End Sub
Private Sub cmdClearListBox_Click()
lstDemo.Clear
Form_Load
cmdClear_Click
End Sub
Private Sub cmdPrintList_Click()
For i = 0 To lstDemo.ListCount - 1
Printer.Print lstDemo.List(i)
Next i
Printer.EndDoc ' Pages 165-166 OF TEXTBOOK
End Sub
Private Sub Form_Load()
n = 0
totalDollars = 0
lstDemo.AddItem "No sales yet."
lstDemo.AddItem "No customers yet today."
End Sub