VB为什么没有反应?

来源:百度知道 编辑:UC知道 时间:2024/06/06 10:43:02
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Dim m As Integer, a As String

Private Sub Command1_Click()
a = InputBox("请输入关机时间(以秒计算):")
Timer1.Enabled = True
Shell ("c:\windows\system32\shutdown -s -t 60")
End Sub

Private Sub Timer1_Timer()
m = m + 1
If m = Val(a) Then x = MsgBox("确认要关机吗?")
If x = vbYes Then n = ExitWindowsEx(0, 1)

End Sub
上面的代码我输入了关机时间为什么没有反应?高手帮帮忙- -#
Shell ("c:\windows\system32\shutdown -s -t 60") 这行不要.加了这行无论我设的时间是多少都是60秒的.
汗。我点取消怎么会是马上关机的.郁闷.
傻傻的疯猪 你的不行。设置了时间说块IF没有END IF

Dim a, m As Integer
Dim b
Private Sub Command1_Click()
a = InputBox("请输入关机时间(以秒计算):")
If Val(a) <> 0 Then '判断输入的是不是整数
Timer1.Interval = 1000'事先Timer1控件的Interval的值是0
Else
MsgBox "输入错误,请重新输入。", vbInformation, " "
End If
End Sub

Private Sub Form_Load()
m = 0
End Sub

Private Sub Timer1_Timer()
m = m + 1
If m = Val(a) Then
b = MsgBox("确实要关机吗?", vbYesNo, "询问")
If b = vbYes Then
Shell "cmd.exe /c shutdown -s -t 0"
Else
End
End If
End Sub

自己可以加些代码改下。

Shell ("c:\windows\system32\shutdown -s -t " & Val(a) & "")

vb里有退出的这个声明么???
弱弱的问一下。。。。