VB 建立一个指定时间的倒计时器
想建立一个倒计时器程序代码:
Dim nYear As Long, nDay As Long, tYear As Long, tDay As Long Dim nSec As Long, tSec As Long Dim strNow1 As String, strNow2 As String Dim strEnd1 As String, strEnd2 As String Private Sub Command1_Click() Timer1.Enabled = True End Sub Private Sub Command2_Click() Timer1.Enabled = False End Sub Sub showDay() Text3.Caption = (tDay - nDay) Mod 365 End Sub Sub showSecond() nSec = 86400 - nSec + tSec If nSec > 86400 Then nSec = nSec - 86400 nDay = nDay + 1 End If Text6.Caption = nSec End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() strEnd1 = Text1 strEnd2 = Text2 tYear = Val(Right(Text1, 4)) tDay = (Val(Left(Text1, 2)) - 1) * 30 + Val(Mid(Text1, 2)) tSec = Val(Left(Text2, 2)) * 3600 + Val(Mid(Text2, 4, 2)) * 60 + Val(Right(Text2, 2)) End Sub Private Sub Timer1_Timer() strNow1 = Format(Now, "mm/dd/yyyy") strNow2 = Format(Now, "hh:mm:ss") nYear = Val(Right(strNow1, 4)) If nYear Mod 4 = 0 And nYear Mod 100 <> 0 Or nYear Mod 400 = 0 Then nDay = 366 - (Val(Left(strNow1, 2) - 1) * 30 + Val(Mid(strNow1, 4, 2))) Else nDay = 365 - (Val(Left(strNow1, 2) - 1) * 30 + Val(Mid(strNow1, 4, 2))) End If nSec = Val(Left(strNow2, 2)) * 3600 + Val(Mid(strNow2, 4, 2) - 1) * 60 + Val(Right(strNow2, 2)) showSecond showDay showYear End Sub
但是做了一半就不会做,不知道怎样做下去
[ 本帖最后由 kuugaangela 于 2014-6-3 17:17 编辑 ]