Private Sub Command1_Click()
If Command1.Caption = "暂停" Then
Command1.Caption = "继续"
Timer1.Enabled = False
Else
Command1.Caption = "暂停"
If Label1.Caption = "00:00:00:0" Then Form1.Tag = Timer
Timer1.Enabled = False
End If
End SubPrivate Sub Command2_Click()
这是设计一个计时器的程序代码:
Form1.Tag = Timer
Label1.Caption = "00:00:00:0"
End SubPrivate Sub Timer1_Timer()
m = Timer - Form1.Tag
n0 = (m * 10) Mod 10
m = Int(m)
n1 = Format(m Mod 60, "00,")
n2 = Format((m \ 60) Mod 60, "00:")
n3 = Format(m \ 3600, "00:")
Label1.Caption = n3 & n2 & n1 & n0
End Sub
运行的时候没有错误,可是一点开始,没有计时啊;是不是哪一个控件的属性没有设好啊?
再说,timer函数返回的不是从午夜到此时的秒数吗;Form1.Tag = Timer,m = Timer - Form1.Tag
怎么减啊?
小儿科,但是我自学,有点想通;;;;
请各位老师解释一下上面的程序;;;;;;;;;谢谢!
If Command1.Caption = "暂停" Then
Command1.Caption = "继续"
Timer1.Enabled = False
Else
Command1.Caption = "暂停"
If Label1.Caption = "00:00:00:0" Then Form1.Tag = Timer
Timer1.Enabled = False
End If
End SubPrivate Sub Command2_Click()
这是设计一个计时器的程序代码:
Form1.Tag = Timer
Label1.Caption = "00:00:00:0"
End SubPrivate Sub Timer1_Timer()
m = Timer - Form1.Tag
n0 = (m * 10) Mod 10
m = Int(m)
n1 = Format(m Mod 60, "00,")
n2 = Format((m \ 60) Mod 60, "00:")
n3 = Format(m \ 3600, "00:")
Label1.Caption = n3 & n2 & n1 & n0
End Sub
运行的时候没有错误,可是一点开始,没有计时啊;是不是哪一个控件的属性没有设好啊?
再说,timer函数返回的不是从午夜到此时的秒数吗;Form1.Tag = Timer,m = Timer - Form1.Tag
怎么减啊?
小儿科,但是我自学,有点想通;;;;
请各位老师解释一下上面的程序;;;;;;;;;谢谢!
解决方案 »
- 谁知道vb中timer控件的时间最长是多长啊?
- 帮我看一下程序啊,我不知道错哪里了
- 怎么去掉字符串中间的空格
- 加载程序的时候提示:控件 PETOCX1 的类 PETOCXLib.PETOCX 不是一个已加载的控件类。我该怎么做啊???急!!!!
- 在EXCEL中用VBA 怎么才能自动增加列
- 有什么办法可以在vb的程序里打开png pcx 的图片呀
- 请问那里有VB6 下载
- 关于MS Inertnet Transfer Control的问题,急
- 急救 :( 一个关于按钮的问题
- 在listview控件中如何定位?如何在某列按条件搜索某值?
- 如何实现这样的功能,请各路大侠帮帮我
- 在vb中怎样控制水晶报表4.6中预览窗口中打印按纽失效呢?急急急急急急急急急急急急急急
'随手写的,我机子刚镜像还原,还没装 VB ,代码没调试可能会错误。Dim StartTime As Date '定义一个全局变量保存起始时间。用 Me.Tag 属性保存虽然也行但是不好,因为它是 String 类型的。Private Sub Command1_Click() If Timer1.Enabled Then
Command1.Caption="继续"
Else
Command1.Caption="暂停"
End If Timer1.Enabled=Not Timer1.EnabledEnd SubPrivate Sub Command2_Click()
'这是设计一个计时器的程序代码:
StartTime=Now
Label1.Caption = "00:00:00:0"
End SubPrivate Sub Timer1_Timer()
Label1.Caption = Format(Now-StartTime,"HH:MM:SS")
End Sub
If Command1.Caption = "暂停" Then
Command1.Caption = "继续"
Timer1.Enabled = False
Else
Command1.Caption = "暂停"
If Label1.Caption = "00:00:00:0" Then Form1.Tag = Timer
Timer1.Enabled = True
End If
End SubPrivate Sub Command2_Click()
'这是设计一个计时器的程序代码:
Form1.Tag = Timer
Label1.Caption = "00:00:00:0"
End SubPrivate Sub Timer1_Timer()
m = Timer - Form1.Tag
n0 = (m * 10) Mod 10
m = Int(m)
n1 = Format(m Mod 60, "00,")
n2 = Format((m \ 60) Mod 60, "00:")
n3 = Format(m \ 3600, "00:")
Label1.Caption = n3 & n2 & n1 & n0
End Sub