使用VB-NET制作定时关机程序.doc
Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-date使用VB-NET制作定时关机程序使用VB-NET制作定时关机程序使用VB.NET制作多功能自动关机程序1、程序功能:自定义倒计时关机;设定时间关机。2、界面,三个按钮,五个标签,三个文本框,一个计时器标签53、源代码Public Class Form1 Public h, m, hc, mc As Integer '小时,分钟,剩余小时,剩余分钟 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tm As Integer tm = Val(TextBox1.Text) * 60 If tm > 0 Then System.Diagnostics.Process.Start("Shutdown.exe", " -s -t " & tm) Label5.Text = "正在倒计时关机" End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() System.Diagnostics.Process.Start("Shutdown.exe", " -a") Label5.Text = "定时关机已取消" End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click h = Val(TextBox2.Text) m = Val(TextBox3.Text) If h = 0 And m = 0 Then MsgBox("输入时间错误", , "请输入时间") ElseIf h > 24 Or h < 0 Or m > 60 Or m < 0 Then MsgBox("输入时间错误", , "请检查输入时间") Else Timer1.Start() End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick '时间间隔interval可设置为3000,即3秒刷新一次 If h = Now.Hour And m = Now.Minute Then System.Diagnostics.Process.Start("Shutdown.exe", " -s -f -t 3") End If hc = h - Now.Hour mc = m - Now.Minute If hc < 0 Then hc = hc + 24 End If If mc < 0 Then hc = hc - 1 mc = mc + 60 End If Label5.Text = "距离关机还有" & hc & "小时" & mc & "分钟" End SubEnd Class-