VB如何使用timer控件?

来源:百度知道 编辑:UC知道 时间:2024/05/14 12:43:27
我设定120分钟后运行一个动作,让家里的电脑自动关机,而timer最多Intervel只有60000属性,到不了30分钟.
那我怎么写程序呢?

Private Sub Timer1_Timer()

shell "c:\shutdown.exe"

End Sub

设置一个静态变量如:将Timer1的Intervel设置为1000
Private Sub Timer1_Timer()
static t as long

if t>120*60 then
shell "c:\shutdown.exe"
timer1.enabled=false
else
t=t+1
end if

End Sub

设置60000运行一次闹钟,也就是1分钟。
Private Sub Load() '这是初始化函数,名字不太记得
Dim i
i=0
End Sub
Private Sub Timer1_Timer()
i=i+1
if i=120 then '一分钟运行一次,于是第120分钟会执行关机。
shell "c:\shutdown.exe"
end if
End Sub

如果是为了解决问题就没必要有TIMER控件,你直接用text控件就行,只要在里面输入关机的时间就行了
Private Sub Load()
dim t!
t=text1.text;
if t=3:00
then shell "c:\shutdown.exe";
end if
end sub
上面的3:00由你自己填