VERSION 5.00 Begin VB.Form Form1 Caption = "June 25th, 2002 ListBox example" Begin VB.CommandButton cmdColorShow Caption = "Color Show" End Begin VB.Timer Timer1 Enabled = 0 'False Interval = 1000 End Begin VB.CommandButton cmdAddColor Caption = "Add Color" End Begin VB.ListBox lstColors ItemData = "ColorShow.frx":0000 List = "ColorShow.frx":0010 Sorted = -1 'True End End ' Review of ListBox control and the Tuesday, June 25th, 2002 hands-on class Private Sub cmdAddColor_Click() theColor = InputBox("What is the new color value?" & vbCrLf & _ "Enter a number between 0 and 16777215") If theColor >= 0 And theColor < 16777216 Then lstColors.AddItem theColor End If End Sub Private Sub cmdColorShow_Click() Timer1.Enabled = True lstColors.ListIndex = 0 End Sub Private Sub Form_Load() Randomize End Sub Private Sub lstColors_Click() c = lstColors.Text If c = "Blue" Then Form1.BackColor = vbBlue ElseIf c = "Red" Then Form1.BackColor = vbRed ElseIf c = "Green" Then Form1.BackColor = vbGreen ElseIf c = "Random" Then theColor = Int(Rnd * 16) Form1.BackColor = QBColor(theColor) Else Form1.BackColor = CLng(c) End If End Sub Private Sub Timer1_Timer() lstColors_Click nextColor = lstColors.ListIndex + 1 If nextColor = lstColors.ListCount Then Timer1.Enabled = False Else lstColors.ListIndex = nextColor End If End Sub