TextBox、Temer、CommandButton各一个 Private Sub Command1_Click() Timer1.Interval = Text1.Text End SubPrivate Sub Timer1_Timer() Print "Hello!!!" Timer1.Interval = 0 End Sub 这是前半部分。 而后半部分,退出、重起后继续倒记时,就不会做了!
'一个timer1,一个label1 Dim cs As IntegerPrivate Sub Form_Load() cs = 0 Timer1.Interval = 1000 End SubPrivate Sub Timer1_Timer() On Error Resume Next cs = cs + 1 Label1.Caption = "到计时:" & Str(6 - cs) If cs = 6 Then MsgBox "时间到!" Unload Me End IfEnd Sub
接着 jxgzay所写保存时用: dim filename as String '文件名 open filename for output as #1 print #1,cs close #fn 读数据时: dim filename as String '文件名 open filename for input as #1 dim thenum as Integer line input #1,thenum cs=thenum close #fn 就能接着计时了。
两个都错了,close #fn 应为close #filename
接着 jxgzay所写保存时用: dim filename as String '文件名 open filename for output as #1 print #1,cs close #filename 读数据时: dim filename as String '文件名 open filename for input as #1 dim thenum as Integer line input #1,thenum cs=thenum close #filename 就能接着计时了。-------------------------------- 给filename值啊,filename="c:\systimer.dll" 应该不会错啊~
明白楼上的方法了!我再试试!谢谢!小的用GetSetting、SaveSetting也实现了,但只能放在 HKEY_CURRENT_USER\Software\VB and VBA Program Settings下面, 据说要放到别处需要其他API函数实现。请问注册表中的HKEY_CURRENT_USER\Software\VB and VBA Program Settings项 , 是系统自带的还是安装Visual Basic后才有的?如果是自带,哪些版本的Windows有呀?
楼主的程序如果非正常退出,要在下次启动的时候继续,那也行啊,你可以在每次减少时间的时候(每秒)都往注册表里写值,这样都不会漏了。还有HKEY_CURRENT_USER\Software\VB and VBA Program Settings,这个项不管系统有没有,当你使用"SetSetting"函数的时候都会创建的。具体这个函数的用法请查阅MSDN! 这个是最方便的,没必要用INI文件。
Private Sub Command1_Click()
Timer1.Interval = Text1.Text
End SubPrivate Sub Timer1_Timer()
Print "Hello!!!"
Timer1.Interval = 0
End Sub
这是前半部分。
而后半部分,退出、重起后继续倒记时,就不会做了!
Dim cs As IntegerPrivate Sub Form_Load()
cs = 0
Timer1.Interval = 1000
End SubPrivate Sub Timer1_Timer()
On Error Resume Next
cs = cs + 1
Label1.Caption = "到计时:" & Str(6 - cs)
If cs = 6 Then
MsgBox "时间到!"
Unload Me
End IfEnd Sub
然后在程序启动时去读标记和时间而已。。
可以用timer控件去保存标记~~~
Load里读取上次保存的时间,并接着run
dim filename as String '文件名
open filename for output as #1
print #1,cs
close #fn
读数据时:
dim filename as String '文件名
open filename for input as #1
dim thenum as Integer
line input #1,thenum
cs=thenum
close #fn
就能接着计时了。
应为close #filename
dim filename as String '文件名
open filename for output as #1
print #1,cs
close #filename
读数据时:
dim filename as String '文件名
open filename for input as #1
dim thenum as Integer
line input #1,thenum
cs=thenum
close #filename
就能接着计时了。--------------------------------
给filename值啊,filename="c:\systimer.dll"
应该不会错啊~
HKEY_CURRENT_USER\Software\VB and VBA Program Settings下面,
据说要放到别处需要其他API函数实现。请问注册表中的HKEY_CURRENT_USER\Software\VB and VBA Program Settings项 ,
是系统自带的还是安装Visual Basic后才有的?如果是自带,哪些版本的Windows有呀?
这个是最方便的,没必要用INI文件。