以下是本人自制的自动关机小程序,VB编写,仅供菜鸟参考,高手请绕道吧!
本程序能在XP,win7等等系统下使用
主界面如下:
这是from1
要是您觉得不好看,完全可以自己设置的,只是我做的有点匆忙,所以没有考虑皮肤。
这是from2
这是from3
代码在下面,菜鸟可以直接复制啊,改一改就可以用了,想要源代码的联系我QQ吧,下面有。
下面是参考程序:
from1里面:
Option Explicit
Dim a, b, c, hh, mm, ss As Integer
Dim sum, time1, aa As Long
Private Sub Command1_Click()
  a = Val(Text1.Text)
  b = Val(Text2.Text)
  c = Val(Text3.Text)
  sum = a * 3600 + b * 60 + c
If Command1.Caption = "开启" Then
  Command1.Caption = "取消"
  Text1.Enabled = False
  Text2.Enabled = False
  Text3.Enabled = False
    If Label3.Caption = "小时" Then
          If sum <= 0 Then
            MsgBox ("猪,你输错时间了!")
            Unload Me
            Me.Show
          Else
            Timer2.Enabled = True
            Timer2.Interval = 1000
          End If
    Else
          If a >= 0 And a <= 24 And b >= 0 And b <= 59 And c >= 0 And c <= 59 Then
            Timer2.Enabled = True
            Timer2.Interval = 1000
          Else
            MsgBox ("笨蛋,有这时间吗?")
            Unload Me
            Me.Show
          End If
    End If
Else
  Text1.Enabled = True
  Text2.Enabled = True
  Text3.Enabled = True
  Text2.SetFocus
  Command1.Caption = "开启"
  Text1.Text = ""
  Text2.Text = ""
  Text3.Text = ""
  Timer2.Enabled = False
End If
End Sub
Private Sub Command2_Click()
Form3.Show
End Sub
Private Sub Command3_Click()
Unload Form1
Unload Form2
Form1.Show
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Command5_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label3.Caption = "小时"
Label4.Caption = ""
Label5.Caption = ""
Label6.Caption = "后将自动关机"
Label7.Caption = "倒计时模式:请输入倒计时间"
Text2.SetFocus
End Sub
Private Sub Command6_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label3.Caption = ""
Label4.Caption = ""
Label5.Caption = ""
Label6.Caption = "将自动关机"
Label7.Caption = "定时模式:请输入自动关机时间"
Text2.SetFocus
End Sub
Private Sub Form_Activate()
  Text1.Enabled = True
  Text2.Enabled = True
  Text3.Enabled = True
Text2.SetFocus
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
Timer2.Enabled = False
Label2.FontSize = 15
Form1.Left = Screen.Width / 2 - Form1.Width / 2
Form1.Top = Screen.Height / 2 - Form1.Height / 2
Form1.Picture = Nothing
End Sub
Private Sub Timer1_Timer()
Label1.FontSize = 15
Label1.Caption = Time
If Timer2.Enabled = True Then
  Label10.Caption = "已开启"
vb编程基础知识菜鸟Else
  Label10.Caption = "未开启"
End If
End Sub
Private Sub Timer2_Timer()
If Label3.Caption = "小时" Then
  If sum <= 0 Then
    Form2.Show
    Timer2.Enabled = False
    Command1.Caption = "开启"

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。