麻烦高手帮我修改一下下面的vb倒计时编程
在窗体上创建一个计时器Timer1,一个标签LabTimePrivateSubForm_Load()DimDaysAsIntegerDimTimesAsDateTimer...
在窗体上创建一个计时器Timer1,一个标签LabTime
Private Sub Form_Load()
Dim Days As Integer
Dim Times As Date
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Const date0 As Date = #10/1/2009 10:10:10 AM# '日期
Days = CInt(date0 - Now - 0.5) '取整数部分(天数)
Times = CDate(date0 - Now)
LabDay.Caption = Days & "天" & Hour(Times) & "小时" & Minute(Times) & "分" & Second(Times) & "秒"
End Sub
上面的局限性是时间直接在代码中给定,我想问怎么改动可以在运行时随便改时间,比如在窗体上加一个text,然后随便输入所想倒计的任何时间
我想尽快知道答案,请高人的帮忙!快!谢谢~ 展开
Private Sub Form_Load()
Dim Days As Integer
Dim Times As Date
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Const date0 As Date = #10/1/2009 10:10:10 AM# '日期
Days = CInt(date0 - Now - 0.5) '取整数部分(天数)
Times = CDate(date0 - Now)
LabDay.Caption = Days & "天" & Hour(Times) & "小时" & Minute(Times) & "分" & Second(Times) & "秒"
End Sub
上面的局限性是时间直接在代码中给定,我想问怎么改动可以在运行时随便改时间,比如在窗体上加一个text,然后随便输入所想倒计的任何时间
我想尽快知道答案,请高人的帮忙!快!谢谢~ 展开
展开全部
Dim sTotal&, h%, m%, d%, s%
Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
sTotal = DateDiff("s", "00:00:00", Text1.Text)
End Sub
Private Sub Timer1_Timer()
sTotal = sTotal - 1
h = sTotal \ 3600
m = (sTotal Mod 3600) \ 60
s = (sTotal Mod 3600) Mod 60
Text1.Text = h & ":" & m & ":" & s
End Sub
可以实现一天之内的倒计时
Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
sTotal = DateDiff("s", "00:00:00", Text1.Text)
End Sub
Private Sub Timer1_Timer()
sTotal = sTotal - 1
h = sTotal \ 3600
m = (sTotal Mod 3600) \ 60
s = (sTotal Mod 3600) Mod 60
Text1.Text = h & ":" & m & ":" & s
End Sub
可以实现一天之内的倒计时
展开全部
Private Sub Form_Load()
dim date0 As Date '放在这儿
text1.text=now()
date0=text1.text
dim date0 As Date '放在这儿
text1.text=now()
date0=text1.text
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
dim date0 As Date
text1.text=now()
date0=text1.text
dim date0 As Date
text1.text=now()
date0=text1.text
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询