关于定时关机快到时间弹出确认的问题
各位大侠,大家好,小弟遇到个问题,我是VB新手,一直解决不了,所以来这里请教一下大家。废话少说,先附上代码:
Private Sub Timer1_Timer()
nowTime = Time
Me.Label2.Caption = Time
If Option1.Value Then
If DateDiff("s", nowTime, txtTime) = 60 Then
Timer1.Enabled = True
If MsgBox("距离关机时间还有一分钟,是否取消?", vbYesNo + vbInformation, "关机确认") = vbYes Then
Timer1.Enabled = False
End If
End If
If DateDiff("s", nowTime, txtTime) = 0 Then
ShutDownPC True
Timer1.Enabled = False
End If
End If
End Sub
我是想在离关机前一分钟弹出提示,如果按了确定按钮呢,是可以取消定时关机的。现在的问题是,我想如果这一分钟里没有任何操作,即没有按确定也没有按取消按钮的情况下继续计时,然后一分钟后关闭电脑。现在这段代码是如果没有操作的话也不执行后面的代码,希望哪位高手帮我看看,先谢了!
在线等,谢谢! 用MessageBox,弹出对话框但不会挂起线程 能说具体点吗?最好是有代码,我是新手,不太懂,麻烦了
写错了 。。。。。。。
Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVaL hwnd As Long, ByVaL lpText As String, ByVaL lpCaption As String, ByVaL wType As Long) As Long
Private Sub Timer1_Timer()
nowTime = Time
Me.Label2.Caption = Time
If Option1.Value Then
If DateDiff("s", nowTime, txtTime) = 60 Then
Timer1.Enabled = True
If MessageBox("距离关机时间还有一分钟,是否取消?", vbYesNo + vbInformation, "关机确认") = vbYes Then
Timer1.Enabled = False
End If
End If
If DateDiff("s", nowTime, txtTime) = 0 Then
ShutDownPC True
Timer1.Enabled = False
End If
End If
End Sub
Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVaL hwnd As Long, ByVaL lpText As String, ByVaL lpCaption As String, ByVaL wType As Long) As Long提示编译错误:参数不可选
Private Sub Timer1_Timer()
nowTime = Time
Me.Label2.Caption = Time
If Option1.Value Then
If DateDiff("s", nowTime, txtTime) = 60 Then
Timer1.Enabled = True
If MessageBox(me.hwnd,"距离关机时间还有一分钟,是否取消?", "关机确认", vbYesNo + vbInformation) = vbYes Then
Timer1.Enabled = False
End If
End If
If DateDiff("s", nowTime, txtTime) = 0 Then
ShutDownPC True
Timer1.Enabled = False
End If
End If
End Sub
是什么意思啊,是不是少了什么参数?
真是不好意思,新手,就20分一直麻烦你 错了错了,是我没看到你代码里的那个me.hwnd.
我试试,先谢了 我也有段时间没用VB了,今天只是碰巧看到这问题,又碰巧记得。。。 大哥,还不行啊,还是会把进程挂起的 不用msgbox,自己做个弹出窗体吧。
补充:VB , API