期望获得的结果→自动做10道题,做每道题间用时小计,总用时统计
谢谢,各位高手参与。**************下面程序是一道计时器示例程序。在下面程序中加一个text控件。回答一道题后,回车→送到一个数组统计。
*********************请教的问题,是否需要用两个timer控件。
Text控件回车后→判断结果正确性→timer如何开始计时,下次回车结束。小计两道题间的用时。*****************
Dim StartTimePrivate Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
StartTime = Time
End SubPrivate Sub Timer1_Timer()
Dim intS As Integer
intS = DateDiff("s", StartTime, Time)
Text1.Text = Format((intS Mod 3600) \ 60, "00") & ":" & Format(intS Mod 60, "00")End Sub
谢谢,各位高手参与。**************下面程序是一道计时器示例程序。在下面程序中加一个text控件。回答一道题后,回车→送到一个数组统计。
*********************请教的问题,是否需要用两个timer控件。
Text控件回车后→判断结果正确性→timer如何开始计时,下次回车结束。小计两道题间的用时。*****************
Dim StartTimePrivate Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
StartTime = Time
End SubPrivate Sub Timer1_Timer()
Dim intS As Integer
intS = DateDiff("s", StartTime, Time)
Text1.Text = Format((intS Mod 3600) \ 60, "00") & ":" & Format(intS Mod 60, "00")End Sub
St = True '
End SubPrivate Sub Command2_Click() 'Stop 按鈕
St = False
End SubPrivate Sub Command3_Click() 'Clear 按鈕
St = False '關閉碼表計時功能
Text1.Text = 0 '將碼表歸零
Text2.Text = 0
Text3.Text = 0
Text4.Text = 0
Text5.Text = 0
End SubPrivate Sub Command4_Click() 'Quit 按鈕
End '結束程式
End Sub''
Private Sub Form_Load()
Text1.Font = "Times New Roman" '設定相關字型、大小
Text2.Font = "Times New Roman"
Text3.Font = "Times New Roman"
Text4.Font = "Times New Roman"
Text5.Font = "Times New Roman"
Text1.FontSize = 16
Text2.FontSize = 16
Text3.FontSize = 16
Text4.FontSize = 16
Text5.FontSize = 16
Text1.Alignment = 2
Text2.Alignment = 2
Text3.Alignment = 2
Text4.Alignment = 2
Text5.Alignment = 2
Text1.Text = 0 '將碼表歸零
Text2.Text = 0
Text3.Text = 0
Text4.Text = 0
Text5.Text = 0
Me.Text5.Text = "fdsafdsafdsa"
Me.Timer1.Enabled = True
Me.Timer2.Enabled = True
Label1.Caption = 1222
End Sub
Private Sub Timer1_Timer()
If (St = True) Then '若開關是開啟的,則第四欄位(1/100 秒)加一(interval=10ms)
Text4.Text = Text4.Text + 1
Text3.Text = Text3.Text + Text4.Text \ 100 '以下為進位過程
Text4.Text = Text4.Text Mod 100
Text2.Text = Text2.Text + Text3.Text \ 60
Text3.Text = Text3.Text Mod 60
Text1.Text = Text1.Text + Text2.Text \ 60
Text2.Text = Text2.Text Mod 60
End IfEnd SubPrivate Sub Timer2_Timer()
'Me.Text5.Text = Data
Me.Label1.Caption = Time
End Sub
找到一个解决方法,程序调试已过
http://phys.thu.edu.tw/~ctshih/teach/programming/vb_timer.htm
Set Lab = CreateLabel(Form1, "fff", 500, 600)
End Sub
Function CreateLabel(oForm As Form, Caption, x, y)
Dim Lab As Label
Set Lab = oForm.Controls.Add("VB.label", Caption)
With Lab
.Caption = Caption
.Visible = True
.Enabled = True
.Left = x
.Top = y
End With
Set CreateLabel = Lab
End Function