请高手帮忙编一个类似奥运倒计时的VB程序!
发布网友
发布时间:2024-10-16 02:14
我来回答
共2个回答
热心网友
时间:2024-10-16 02:26
添加一个标签框,一个计时器,粘贴如下代码:
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
Label1.autoSize=True
End Sub
Private Sub Timer1_Timer()
Label1.Caption = "距离奥运会开幕还有:" & #8/8/2008# - Date & "天"
End Sub
热心网友
时间:2024-10-16 02:26
建立一个timer1
Option Explicit
Dim Dd As String
Dim D As Integer, S As Integer, M As Integer, H As Integer
Dim Da As String
Private Sub Form_Load()
Form1.AutoRedraw = True
Timer1.Interval = 100
Form1.ForeColor = vbRed
Form1.FontSize = 50
Form1.BackColor = "&HFFFF"
End Sub
Private Sub Timer1_Timer()
Cls
Dd = Format("2008 - 8 - 8 00:00:00", "yyyy-mm-dd hh:mm:ss")
D = DateDiff("d", Date, Dd)
S = Right(Dd, 2) - Right(Time(), 2)
M = Mid(Right(Dd, 8), 4, 2) - Mid(Time(), 4, 2)
If S < 0 Then
S = S + 60
M = M - 1
End If
H = Left(Right(Dd, 8), 2) - Left(Time(), 2)
If M < 0 Then
M = M + 60
H = H - 1
End If
If H < 0 Then
D = D - 1
H = H + 24
End If
Da = D & "天" & H & "小时" & M & "分" & S & "秒"
Print "距离"
Print Dd
Print "还剩"
Print Da
End Sub
已经运行过。
你可以根据需要调整日期和显示的内容。