Click here to Skip to main content
15,891,136 members
Articles / Programming Languages / Visual Basic
Article

ShutDown Timer

Rate me:
Please Sign up or sign in to vote.
1.46/5 (15 votes)
12 Aug 2006CPOL 64K   2.7K   23   6
Set timer to Turn Off your PC

Interface

Introduction

Before going in detail about the application.

This simple programme help you if you want to set timer to turn off your PC after spacified period.

Core behined Code

The most important code in this programme

System.Diagnostics.Process.Start("Shutdown", "/s")

I pass ' Shutdown ' to turn off .

So how am I achieving it? (What is the code behind it?)

first I used timer of course to increese variables every Tick of timer :-

This snap shot of code

this global var
Dim x,min,cou,hh As Integer = 0


Private Sub Timer1_Tick

'For each tick

'here I make counter

'x second

x = x + 1

If x = 60 Then

x = 0

min = min + 1

ProgressBar1.Value = ProgressBar1.Value + 1

End If

If min = 60 Then

hh += 1

min = 0

End If

Label5.Text = hh

'to display the timer

Label4.Text = x

Label3.Text = min

'NumericUpDown1 Input of hour

'NumericUpDown1 Input of hour
'NumericUpDown1 Input of hour

Dim tothor As Integer = Int32.Parse(NumericUpDown1.Value)

Dim totmin As Integer = Int32.Parse(NumericUpDown2.Value)

tothor = tothor * 60

Dim total As Double = tothor + totmin

'every tick check if it we achieve total of Minute

Dim totallabel As Double = hh * 60 + min

If totallabel = total Then

cou += 1

wa()

End If

End Sub

Now You can shut down

This sub shutdown pc

VB.NET
Public Sub wa()

If cou = 1 Then

Me.Show()

System.Diagnostics.Process.Start("Shutdown", "/s")

cou += 1

End If

End Sub

Finaly

pop up window will show give 30 second before shutting down.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Jordan Jordan
- Need is the mother of the invitation .
- To be acknowledge is matter of time..
be skillfull..needs...

Comments and Discussions

 
GeneralMy vote of 1 Pin
Muhammady18-Mar-12 10:49
Muhammady18-Mar-12 10:49 
GeneralMy vote of 5 Pin
versx1-Aug-10 21:37
versx1-Aug-10 21:37 
Joke:( Pin
The_Mega_ZZTer13-Aug-06 9:02
The_Mega_ZZTer13-Aug-06 9:02 
GeneralRe: :(hi [modified] Pin
mr.stick13-Aug-06 23:23
mr.stick13-Aug-06 23:23 
Generalhe meant logoff Pin
Fabse_net14-Aug-06 4:02
Fabse_net14-Aug-06 4:02 
GeneralRe: he meant logoff Pin
mr.stick14-Aug-06 8:10
mr.stick14-Aug-06 8:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.