'楼上的代码要稍做修改。
'Text1=系统当前时间
'Text2=设置关机小时
'Text3=设置关机分钟
Private Sub Command1_Click()
MsgBox "设置成功,系统进入定时关机状态"
Me.Visible = False
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Text1 = Now
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Text1 = Now
If Val(Text2) = Hour(Time) And Val(Text3) = Minute(Time) Then
Shell "c:\windows\system32\shutdown -s -t 0", vbHide
End If
End Sub
给你答案啦 调用shutdown命令
Private h As Integer
Private m As Integer
Private Sub Command1_Click()
h = Val(Text2.Text)
m = Val(Text3.Text)
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Text1.Text = Now
If h = Hour(Now) And m = Minute(Now) Then
Shell "c:\windows\system32\shutdown -s -t 0", vbHide
End If
End Sub
API:ExitWindowsEx