用vb做关机
我们微机考试用vb做了2次函数,现在老师让我们做关机的!谁会?不要太复杂的,只要能关机就行!要正确的!...
我们微机考试用vb做了2次函数,现在老师让我们做关机的!
谁会?不要太复杂的,只要能关机就行!要正确的! 展开
谁会?不要太复杂的,只要能关机就行!要正确的! 展开
2个回答
展开全部
调用API,使用函数即可。
以前学过,给一段别人的代码:
Option Explicit
Dim Atime As Date
Private Sub Form1_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub
Private Sub Command1_Click()
If Text2.Text + Text3.Text = "" Then
MsgBox "请输入数字", , "提悉液行示"
Else
Atime = DateAdd("睁哗h", Val(Text2.Text), Now)
Atime = DateAdd("n", Val(Text3.Text), Atime)
Label3.Caption = "您将在" & Atime & "关机"
Timer1.Enabled = True
End If
End Sub
Private Sub Command2_Click()
End '退出程序
End Sub
Private Sub form_load()
Timer1.Interval = 1000 '每1秒执行一次埋陵timer事件
Timer1.Enabled = False
End Sub
Private Sub Text1_Change()
Text1.Enabled = False
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then KeyAscii = 0
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then KeyAscii = 0
End Sub
Private Sub Timer1_Timer()
Text1.Text = Now '在每次次timer来后更新一次时间`~
If Atime >= Now Then Shell "cmd /c shutdown -s -t 0", 0
End Sub
以前学过,给一段别人的代码:
Option Explicit
Dim Atime As Date
Private Sub Form1_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub
Private Sub Command1_Click()
If Text2.Text + Text3.Text = "" Then
MsgBox "请输入数字", , "提悉液行示"
Else
Atime = DateAdd("睁哗h", Val(Text2.Text), Now)
Atime = DateAdd("n", Val(Text3.Text), Atime)
Label3.Caption = "您将在" & Atime & "关机"
Timer1.Enabled = True
End If
End Sub
Private Sub Command2_Click()
End '退出程序
End Sub
Private Sub form_load()
Timer1.Interval = 1000 '每1秒执行一次埋陵timer事件
Timer1.Enabled = False
End Sub
Private Sub Text1_Change()
Text1.Enabled = False
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then KeyAscii = 0
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then KeyAscii = 0
End Sub
Private Sub Timer1_Timer()
Text1.Text = Now '在每次次timer来后更新一次时间`~
If Atime >= Now Then Shell "cmd /c shutdown -s -t 0", 0
End Sub
参考资料: http://zhidao.baidu.com/question/154387981.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询