vb定时器
界面如图所示(最好先和和我的一样):
timer1、command1、text1的index(不是tabindex)属性设为1,list1 的sorted 属性设为true
Dim a(1 To 5) As Integer, b(1 To 5) As Single
Private Sub Command1_Click(Index As Integer)
Timer1(Index).Enabled = False
For i = 1 To 5
If Timer1(i).Enabled = True Then Exit For
Next
If i = 6 And a(1) <> 0 Then
For i = 1 To 5
List1.AddItem Format(b(i), "0.00") & " 第" & i & "组"
Next
End If
End Sub
Private Sub Command2_Click()
For i = 1 To 5
Timer1(i).Enabled = True
Next
End Sub
Private Sub Form_Load()
Timer1(1).Interval = 10
Command1(1).Caption = "第1组"
Command2.Caption = "开始计时"
For i = 2 To 5
Load Text1(i)
Load Timer1(i)
Text1(i).Visible = True
Load Command1(i)
Command1(i).Visible = True
Command1(i).Caption = "第" & i & "组"
Text1(i).Top = Text1(1).Top + 1.25 * Text1(1).Height * (i - 1)
Command1(i).Top = Text1(i).Top
Next
End Sub
Private Sub Timer1_Timer(Index As Integer)
For i = 1 To 5
If Index = i Then a(i) = a(i) + 1
b(i) = a(i) / 100
Text1(i) = Format(b(i), " 0.00")
Next
End Sub