用vb执行关机

来源:百度知道 编辑:UC知道 时间:2024/05/05 19:33:20
我要用VB 6.0设计定时关机的程序。
现在有控件text1 和Command1。我要在text1中输入一个时间,如12:00,现在将这个值传递给Command1中的语令shell "at a shutdown -t" 中的"a",用a = Text1.Text传递 ,但总是有错,是不是定义什么类型不对?(我试了Integer、Variant、date等)。
或者说我在text1中输入一个时间,然后点击Command1执行关机,怎么做?
大家帮我重点想想怎么做到我的后一个问题。
如果我要用两个Text控件,一个写小时,一个写分钟 ,如text1中写12 ,text2中写00,执行12:00关机,怎么做

变量a不能写在引号内,不然就不成为变量,而是a字符了。

Command1事件,如下写:
a=Text1.Text
shell "at " & a & " shutdown -t -s"

试下看看。

Shell "shutdown -s -t 1" '设置关机命令 ,1秒关机,只适合WIN2000以上的系统

Shell "shutdown -s -t 0" '设置关机命令 ,立即关机,只适合WIN2000以上的系统

你改时间就好了.或者,

Dim s1 As String
s1 = Time
if s1 = text1.text & ":" & text2.text & ":00" then Shell "shutdown -s -t 0"

用一个timer控件每秒钟查看一下时间,比较后再执行
Shell shutdown -s -t