打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
VB6.0的倒计时代码(可随意输入小时,分钟,秒数的)格式为:()时()分()秒

平常用用的倒计时代码,时间小于9小时的。

Option Explicit

Private Sub Command1_Click()

  If Command1.Caption = "开始倒计时" Then

   On Error Resume Next

     If Val(Text1.Text) > 9 Then MsgBox "小时数设置过大,请重设": Exit Sub

    If Val(Text2.Text) > 60 Then MsgBox "分钟设置有误,请检查": Exit Sub

    If Val(Text3.Text) > 60 Then MsgBox "秒设置有误,请检查": Exit Sub

    Command1.Caption = "暂停"

    Timer1.Enabled = True

    Text1.Enabled = False

    Text2.Enabled = False

    Text3.Enabled = False

  Else

    Command1.Caption = "开始倒计时"

    Timer1.Enabled = False

    

    Text1.Enabled = True

    Text2.Enabled = True

    Text3.Enabled = True

  End If

End Sub

Private Sub form_load()

  Command1.Caption = "开始倒计时"

  Timer1.Interval = 1000

  Timer1.Enabled = False

  Text2.MaxLength = 2

  Text3.MaxLength = 2

  Text1.Text = 0

  Text2.Text = 0

  Text3.Text = 0

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

  If KeyAscii > Asc(9) Or KeyAscii < Asc(0) Then MsgBox "请输入整数": KeyAscii = 0

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

  If KeyAscii > Asc(9) Or KeyAscii < Asc(0) Then MsgBox "请输入整数": KeyAscii = 0

End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)

  If KeyAscii > Asc(9) Or KeyAscii < Asc(0) Then MsgBox "请输入整数": KeyAscii = 0

End Sub

Private Sub Timer1_Timer()

  Dim h As Integer, m As Integer, s As Integer, total As Double

  h = Val(Text1.Text)

  m = Val(Text2.Text)

  s = Val(Text3.Text)

  total = h * 3600 + m * 60 + s

  total = total - 1

  h = total \ 3600

  m = (total Mod 3600) \ 60

  s = total - h * 3600 - m * 60

  Text1.Text = h

  Text2.Text = m

  Text3.Text = s

  If total = 0 Then MsgBox "时间到!": Timer1.Enabled = False

  End Sub

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
VB MSFlexGrid控件的几种简单的使用方法
vb中msflexgrid的使用举例
《Visual Basic程序设计(第4版)》第4章 顺序结构程序设计
图像像素布纹密码
不要textbox令MshflexGrid有编辑功能
VB.NET限制文本框输入字符
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服