使用VBNET制作定时关机程序.doc
- 文档编号:233970
- 上传时间:2022-10-07
- 格式:DOC
- 页数:3
- 大小:41.50KB
使用VBNET制作定时关机程序.doc
《使用VBNET制作定时关机程序.doc》由会员分享,可在线阅读,更多相关《使用VBNET制作定时关机程序.doc(3页珍藏版)》请在冰豆网上搜索。
使用VB.NET制作多功能自动关机程序
1、程序功能:
自定义倒计时关机;设定时间关机。
2、界面,三个按钮,五个标签,三个文本框,一个计时器
标签5
3、源代码
PublicClassForm1
Publich,m,hc,mcAsInteger'小时,分钟,剩余小时,剩余分钟
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
DimtmAsInteger
tm=Val(TextBox1.Text)*60
Iftm>0Then
System.Diagnostics.Process.Start("Shutdown.exe","-s-t"&tm)
Label5.Text="正在倒计时关机"
EndIf
EndSub
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Click
Timer1.Stop()
System.Diagnostics.Process.Start("Shutdown.exe","-a")
Label5.Text="定时关机已取消"
EndSub
PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.Click
h=Val(TextBox2.Text)
m=Val(TextBox3.Text)
Ifh=0Andm=0Then
MsgBox("输入时间错误",,"请输入时间")
ElseIfh>24Orh<0Orm>60Orm<0Then
MsgBox("输入时间错误",,"请检查输入时间")
Else
Timer1.Start()
EndIf
EndSub
PrivateSubTimer1_Tick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTimer1.Tick
'时间间隔interval可设置为3000,即3秒刷新一次
Ifh=Now.HourAndm=Now.MinuteThen
System.Diagnostics.Process.Start("Shutdown.exe","-s-f-t3")
EndIf
hc=h-Now.Hour
mc=m-Now.Minute
Ifhc<0Then
hc=hc+24
EndIf
Ifmc<0Then
hc=hc-1
mc=mc+60
EndIf
Label5.Text="距离关机还有"&hc&"小时"&mc&"分钟"
EndSub
EndClass
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 使用 VBNET 制作 定时 关机 程序