Shutdown System CountDown [Source]

Discussion in 'Archives' started by Covey, May 29, 2007.

Shutdown System CountDown [Source]
  1. Unread #1 - May 29, 2007 at 6:13 AM
  2. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Shutdown System CountDown [Source]

    Made this for Cool372.

    Basically gives you the option of:
    Restarting.
    Shutdown.
    Logoff

    Under a certain amount of time. Max time limit it will countdown from is 100 hours 40 minutes and 39 seconds. You can change that if you feel its needed.

    Project is Attached.

    Source:
    Code:
    Private Sub cmdEnterTime_Click()
        If cmdEnterTime.Caption = "Enter Time" Then
            lblDisplay = "00:00:00"
            cmdEnterTime.Caption = "Set Time"
            txtHr.Visible = True
            txtMin.Visible = True
            txtSec.Visible = True
            txtHr.SetFocus
        Else
            Dim Hrs As String, Mins As String, Secs As String
            If Val(txtHr) = 0 Then
                Hrs = "00"
            Else
                Hrs = Val(txtHr)
            End If
            If Val(txtMin) >= "60" Then
                Mins = Val(txtMin) - 60
                Hrs = Val(Hrs) + 1
            Else
                Mins = Val(txtMin)
            End If
            If Val(txtSec) >= "60" Then
                Secs = Val(txtSec) - 60
                Mins = Val(Mins) + 1
            Else
                Secs = Val(txtSec)
            End If
            lblDisplay = IIf(Val(Hrs) < 10, "0" & Val(Hrs), Hrs) & ":" & IIf(Val(Mins) < 10, "0" & Val(Mins), Mins) & ":" & IIf(Val(Secs) < 10, "0" & Val(Secs), Secs)
            cmdEnterTime.Caption = "Enter Time"
            txtHr.Visible = False
            txtMin.Visible = False
            txtSec.Visible = False
        End If
    End Sub
    
    Private Sub cmdStart_Click()
        If cmdEnterTime.Caption = "Set Time" Or lblDisplay = "00:00:00" Then
            MsgBox "Please set an amount of time to count down.", vbCritical, "No Time Set"
            Exit Sub
        End If
        If cmdStart.Caption = "S T A R T" Then
            cmdStart.Caption = "S T O P"
            cmdEnterTime.Enabled = False
            tmrShutdown.Enabled = True
        Else
            cmdStart.Caption = "S T A R T"
            cmdEnterTime.Enabled = True
            tmrShutdown.Enabled = False
            lblDisplay = "00:00:00"
        End If
    End Sub
    
    Private Sub tmrShutdown_Timer()
        Dim Hrs As Integer, Mins As Integer, Secs As Integer
        Hrs = Val(Split(lblDisplay, ":")(0))
        Mins = Val(Split(lblDisplay, ":")(1))
        Secs = Val(Split(lblDisplay, ":")(2))
        If Hrs = "0" And Mins = "0" And Secs = "0" Then
            tmrShutdown.Enabled = False
            cmdEnterTime.Enabled = True
            lblDisplay = "00:00:00"
            ShutDownType
            Exit Sub
        End If
        If Secs = "0" Then
            If Mins = "0" Then
                If Not Hrs = "0" Then
                    Hrs = Hrs - 1
                End If
                Mins = "59"
            Else
                Mins = Mins - 1
            End If
            Secs = "59"
        Else
            Secs = Secs - 1
        End If
        lblDisplay = IIf(Hrs < 10, "0" & Hrs, Hrs) & ":" & IIf(Mins < 10, "0" & Mins, Mins) & ":" & IIf(Secs < 10, "0" & Secs, Secs)
    End Sub
    
    Private Sub ShutDownType()
        If Option1(0).Value = True Then
            Shell "Shutdown -s"
        ElseIf Option1(1).Value = True Then
            Shell "Shutdown -l"
        ElseIf Option1(2).Value = True Then
            Shell "Shutdown -r"
        End If
    End Sub
     

    Attached Files:

  3. Unread #2 - May 29, 2007 at 7:56 AM
  4. Repentless
    Joined:
    May 11, 2006
    Posts:
    669
    Referrals:
    3
    Sythe Gold:
    0

    Repentless Apprentice
    Banned

    Shutdown System CountDown [Source]

    I was actually going to make this so I could fall asleep listening to the music on my pc, and then having the pc turn itself off to save power XD Nice, very useful, less work for me now. ;)

    EDIT: Got the .exe for it?
     
  5. Unread #3 - May 29, 2007 at 8:07 AM
  6. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Shutdown System CountDown [Source]

    Added the .exe to it. Re download it.
     
  7. Unread #4 - May 30, 2007 at 9:50 AM
  8. Osmosis
    Joined:
    Apr 29, 2005
    Posts:
    2,695
    Referrals:
    2
    Sythe Gold:
    0

    Osmosis Retired Australian Mod
    Banned

    Shutdown System CountDown [Source]

    Covey, you have to change the timer value to 1000, as it's set to 10 and take the seconds as milliseconds ect...
     
  9. Unread #5 - May 30, 2007 at 10:15 AM
  10. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Shutdown System CountDown [Source]

    my bad, i had it like that so i could test the hours counted down correctly. Forgot to change it back :(
     
< Selling lvl 109 main, f cape, b gloves, gilded alter, quest cape, 1650+ total. | P A R I S's MM Service >

Users viewing this thread
1 guest


 
 
Adblock breaks this site