Private tcount As Long Private Sub Form_Load() tcount = 0 Timer1.Interval = 1000 End Sub Private Sub Timer1_Timer() tcount = tcount + 1 If tcount Mod 240 = 0 Then Time = CDate("09:20:00") End If end sub
没接触过,估计说了方法也不明白。 把下面的代码保存为 .frm 文件,然后用 vb6 打开运行就可以了。需要的话自己编译一下。 VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.Timer Timer1 Interval = 1000 Left = 1755 Top = 1185 End Begin VB.Label Label1 Appearance = 0 'Flat BackColor = &H80000005& BorderStyle = 1 'Fixed Single Caption = "Label1" ForeColor = &H80000008& Height = 375 Left = 1380 TabIndex = 0 Top = 435 Width = 1140 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option ExplicitPrivate preTimer As LongPrivate Sub Form_Load() preTimer = Timer Label1.Caption = "00:00" End SubPrivate Sub Timer1_Timer() Dim t As Long t = Timer - preTimer Label1.Caption = Right("0" & CStr(t \ 60), 2) & ":" & Right("0" & CStr(t Mod 60), 2)
If t >= 8 * 60 Then '时间到 Time = "09:20:00" preTimer = Timer End If End Sub
Private Sub Form_Load()
tcount = 0
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
tcount = tcount + 1
If tcount Mod 240 = 0 Then
Time = CDate("09:20:00")
End If
end sub
把下面的代码保存为 .frm 文件,然后用 vb6 打开运行就可以了。需要的话自己编译一下。
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Interval = 1000
Left = 1755
Top = 1185
End
Begin VB.Label Label1
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
Caption = "Label1"
ForeColor = &H80000008&
Height = 375
Left = 1380
TabIndex = 0
Top = 435
Width = 1140
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate preTimer As LongPrivate Sub Form_Load()
preTimer = Timer
Label1.Caption = "00:00"
End SubPrivate Sub Timer1_Timer()
Dim t As Long
t = Timer - preTimer
Label1.Caption = Right("0" & CStr(t \ 60), 2) & ":" & Right("0" & CStr(t Mod 60), 2)
If t >= 8 * 60 Then
'时间到
Time = "09:20:00"
preTimer = Timer
End If
End Sub