| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 392 人关注过本帖, 1 人收藏
标题:VB 建立一个指定时间的倒计时器
取消只看楼主 加入收藏
kuugaangela
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-5-11
结帖率:0
收藏(1)
已结贴  问题点数:20 回复次数:0 
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 编辑 ]
2014-06-03 17:16
快速回复:VB 建立一个指定时间的倒计时器
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.066336 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved