home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / A_Log_Off_211961772008.psc / Form1.frm < prev    next >
Text File  |  2008-07-03  |  11KB  |  350 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "TIME OUT"
  5.    ClientHeight    =   4260
  6.    ClientLeft      =   45
  7.    ClientTop       =   405
  8.    ClientWidth     =   4755
  9.    BeginProperty Font 
  10.       Name            =   "Arial"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    Icon            =   "Form1.frx":0000
  19.    LinkTopic       =   "Form1"
  20.    MaxButton       =   0   'False
  21.    MinButton       =   0   'False
  22.    Picture         =   "Form1.frx":030A
  23.    ScaleHeight     =   4260
  24.    ScaleWidth      =   4755
  25.    StartUpPosition =   3  'Windows Default
  26.    Begin VB.Frame Frame1 
  27.       BackColor       =   &H00000000&
  28.       Caption         =   "        Remaining Time"
  29.       BeginProperty Font 
  30.          Name            =   "Arial"
  31.          Size            =   15.75
  32.          Charset         =   0
  33.          Weight          =   700
  34.          Underline       =   0   'False
  35.          Italic          =   0   'False
  36.          Strikethrough   =   0   'False
  37.       EndProperty
  38.       ForeColor       =   &H00FFFFFF&
  39.       Height          =   1215
  40.       Left            =   210
  41.       TabIndex        =   9
  42.       Top             =   2820
  43.       Width           =   4305
  44.       Begin VB.Label Label2 
  45.          AutoSize        =   -1  'True
  46.          BackStyle       =   0  'Transparent
  47.          Caption         =   "This computer will"
  48.          BeginProperty Font 
  49.             Name            =   "Arial"
  50.             Size            =   12
  51.             Charset         =   0
  52.             Weight          =   700
  53.             Underline       =   0   'False
  54.             Italic          =   0   'False
  55.             Strikethrough   =   0   'False
  56.          EndProperty
  57.          ForeColor       =   &H0000FF00&
  58.          Height          =   285
  59.          Left            =   150
  60.          TabIndex        =   10
  61.          Top             =   450
  62.          Visible         =   0   'False
  63.          Width           =   2085
  64.       End
  65.    End
  66.    Begin VB.CommandButton cmdabort 
  67.       Caption         =   "ABORT"
  68.       Enabled         =   0   'False
  69.       BeginProperty Font 
  70.          Name            =   "Arial"
  71.          Size            =   14.25
  72.          Charset         =   0
  73.          Weight          =   700
  74.          Underline       =   0   'False
  75.          Italic          =   0   'False
  76.          Strikethrough   =   0   'False
  77.       EndProperty
  78.       Height          =   1005
  79.       Left            =   2580
  80.       Picture         =   "Form1.frx":1192B
  81.       Style           =   1  'Graphical
  82.       TabIndex        =   8
  83.       Top             =   1590
  84.       Width           =   1455
  85.    End
  86.    Begin VB.OptionButton Option3 
  87.       Appearance      =   0  'Flat
  88.       BackColor       =   &H80000005&
  89.       Caption         =   "Shutdown"
  90.       BeginProperty Font 
  91.          Name            =   "Arial"
  92.          Size            =   9.75
  93.          Charset         =   0
  94.          Weight          =   700
  95.          Underline       =   0   'False
  96.          Italic          =   0   'False
  97.          Strikethrough   =   0   'False
  98.       EndProperty
  99.       ForeColor       =   &H80000008&
  100.       Height          =   255
  101.       Left            =   3180
  102.       TabIndex        =   6
  103.       Top             =   240
  104.       Width           =   1455
  105.    End
  106.    Begin VB.OptionButton Option2 
  107.       Appearance      =   0  'Flat
  108.       BackColor       =   &H80000005&
  109.       Caption         =   "Restart"
  110.       BeginProperty Font 
  111.          Name            =   "Arial"
  112.          Size            =   9.75
  113.          Charset         =   0
  114.          Weight          =   700
  115.          Underline       =   0   'False
  116.          Italic          =   0   'False
  117.          Strikethrough   =   0   'False
  118.       EndProperty
  119.       ForeColor       =   &H80000008&
  120.       Height          =   255
  121.       Left            =   1650
  122.       TabIndex        =   5
  123.       Top             =   240
  124.       Width           =   1305
  125.    End
  126.    Begin VB.OptionButton Option1 
  127.       Appearance      =   0  'Flat
  128.       BackColor       =   &H80000005&
  129.       Caption         =   "Log Off"
  130.       BeginProperty Font 
  131.          Name            =   "Arial"
  132.          Size            =   9.75
  133.          Charset         =   0
  134.          Weight          =   700
  135.          Underline       =   0   'False
  136.          Italic          =   0   'False
  137.          Strikethrough   =   0   'False
  138.       EndProperty
  139.       ForeColor       =   &H80000008&
  140.       Height          =   255
  141.       Left            =   120
  142.       TabIndex        =   4
  143.       Top             =   240
  144.       Width           =   1215
  145.    End
  146.    Begin VB.CommandButton cmdexecute 
  147.       Caption         =   "EXECUTE"
  148.       BeginProperty Font 
  149.          Name            =   "Arial"
  150.          Size            =   14.25
  151.          Charset         =   0
  152.          Weight          =   700
  153.          Underline       =   0   'False
  154.          Italic          =   0   'False
  155.          Strikethrough   =   0   'False
  156.       EndProperty
  157.       Height          =   1005
  158.       Left            =   750
  159.       Picture         =   "Form1.frx":11C35
  160.       Style           =   1  'Graphical
  161.       TabIndex        =   7
  162.       Top             =   1590
  163.       Width           =   1455
  164.    End
  165.    Begin VB.Timer Timer1 
  166.       Enabled         =   0   'False
  167.       Interval        =   990
  168.       Left            =   4110
  169.       Top             =   1830
  170.    End
  171.    Begin VB.ComboBox Combo3 
  172.       BeginProperty Font 
  173.          Name            =   "Arial"
  174.          Size            =   12
  175.          Charset         =   0
  176.          Weight          =   700
  177.          Underline       =   0   'False
  178.          Italic          =   0   'False
  179.          Strikethrough   =   0   'False
  180.       EndProperty
  181.       ForeColor       =   &H00FF0000&
  182.       Height          =   405
  183.       Left            =   3450
  184.       Style           =   2  'Dropdown List
  185.       TabIndex        =   3
  186.       Top             =   930
  187.       Width           =   855
  188.    End
  189.    Begin VB.ComboBox Combo2 
  190.       BeginProperty Font 
  191.          Name            =   "Arial"
  192.          Size            =   12
  193.          Charset         =   0
  194.          Weight          =   700
  195.          Underline       =   0   'False
  196.          Italic          =   0   'False
  197.          Strikethrough   =   0   'False
  198.       EndProperty
  199.       ForeColor       =   &H00FF0000&
  200.       Height          =   405
  201.       Left            =   1830
  202.       Style           =   2  'Dropdown List
  203.       TabIndex        =   2
  204.       Top             =   930
  205.       Width           =   855
  206.    End
  207.    Begin VB.ComboBox Combo1 
  208.       BeginProperty Font 
  209.          Name            =   "Arial"
  210.          Size            =   12
  211.          Charset         =   0
  212.          Weight          =   700
  213.          Underline       =   0   'False
  214.          Italic          =   0   'False
  215.          Strikethrough   =   0   'False
  216.       EndProperty
  217.       ForeColor       =   &H00FF0000&
  218.       Height          =   405
  219.       Left            =   180
  220.       Style           =   2  'Dropdown List
  221.       TabIndex        =   1
  222.       Top             =   930
  223.       Width           =   855
  224.    End
  225.    Begin VB.Label Label1 
  226.       AutoSize        =   -1  'True
  227.       BackStyle       =   0  'Transparent
  228.       Caption         =   "Hour(s)            Minute(s)         Second(s)"
  229.       BeginProperty Font 
  230.          Name            =   "Arial"
  231.          Size            =   12
  232.          Charset         =   0
  233.          Weight          =   700
  234.          Underline       =   0   'False
  235.          Italic          =   0   'False
  236.          Strikethrough   =   0   'False
  237.       EndProperty
  238.       ForeColor       =   &H0000FF00&
  239.       Height          =   285
  240.       Left            =   180
  241.       TabIndex        =   0
  242.       Top             =   630
  243.       Width           =   4335
  244.    End
  245. End
  246. Attribute VB_Name = "Form1"
  247. Attribute VB_GlobalNameSpace = False
  248. Attribute VB_Creatable = False
  249. Attribute VB_PredeclaredId = True
  250. Attribute VB_Exposed = False
  251. Option Explicit
  252. Dim c As String
  253. Dim h, m, s As Integer
  254.  
  255. Private Sub enable()
  256. Option1.Enabled = Not Option1.Enabled
  257. Option2.Enabled = Not Option2.Enabled
  258. Option3.Enabled = Not Option3.Enabled
  259. Combo1.Enabled = Not Combo1.Enabled
  260. Combo2.Enabled = Not Combo2.Enabled
  261. Combo3.Enabled = Not Combo3.Enabled
  262. cmdexecute.Enabled = Not cmdexecute.Enabled
  263. cmdabort.Enabled = Not cmdabort.Enabled
  264. Label2.Visible = Not Label2.Visible
  265. Timer1.Enabled = Not Timer1.Enabled
  266. End Sub
  267.  
  268. Private Sub cmdabort_Click()
  269. If MsgBox("Are you sure ?", vbYesNo, "System Message") = vbYes Then
  270. enable
  271. Me.Caption = "TIME OUT"
  272. End If
  273. End Sub
  274.  
  275. Private Sub cmdexecute_Click()
  276. If (Combo1.Text <> "" And Combo2.Text <> "" And Combo3.Text <> "") And (Option1.Value Or Option2.Value Or Option3.Value) Then
  277. If Option1.Value Then 'same as of If Option1.Value=True Then
  278. c = "log off"
  279. ElseIf Option2.Value Then 'same as of ElseIf Option2.Value=True Then
  280. c = "restart"
  281. Else
  282. c = "shutdown"
  283. End If
  284. h = Val(Combo1.Text)
  285. m = Val(Combo2.Text)
  286. s = Val(Combo3.Text)
  287. enable
  288. Else
  289. MsgBox "Please fill up the following : Hour(s), Minute(s), Second(s) and also choose any of the following : Log Off, Restart and Shutdown.", vbExclamation, "System Message"
  290. End If
  291. End Sub
  292.  
  293. Private Sub Form_Load()
  294. For h = 0 To 59
  295. Combo1.AddItem h
  296. Combo2.AddItem h
  297. Combo3.AddItem h
  298. Next h
  299. End Sub
  300.  
  301. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
  302. Option1.ForeColor = vbBlack
  303. Option2.ForeColor = vbBlack
  304. Option3.ForeColor = vbBlack
  305. End Sub
  306.  
  307. Private Sub Form_Unload(Cancel As Integer)
  308. If MsgBox("Are you sure ?", vbYesNo, "System Message") <> vbYes Then
  309. Cancel = 1
  310. Me.WindowState = 1
  311. End If
  312. End Sub
  313.  
  314. Private Sub Option1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
  315. Option1.ForeColor = vbBlue
  316. End Sub
  317.  
  318. Private Sub Option2_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
  319. Option2.ForeColor = vbBlue
  320. End Sub
  321.  
  322. Private Sub Option3_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
  323. Option3.ForeColor = vbBlue
  324. End Sub
  325.  
  326. Private Sub Timer1_Timer()
  327. Label2.Caption = "This computer will " & c & Chr(13) & "  itself after : " & Format(h, "00:") & Format(m, "00:") & Format(s, "00")
  328. Me.Caption = Right(Label2.Caption, 8)
  329. If h = 0 And m = 0 And s = 0 Then
  330. If c = "log off" Then
  331. Shell "shutdown -l" 'This line will log off your computer
  332. ElseIf c = "restart" Then
  333. Shell "shutdown -r -t 00" 'This line will restart your computer
  334. Else
  335. Shell "shutdown -s -t 00" 'This line will shutdown your computer
  336. End If
  337. End 'I write End because sometimes the shell shutdown command is being delayed
  338. End If
  339.  
  340. If s = 0 Then
  341. If m = 0 And h <> 0 Then
  342. h = h - 1
  343. m = 60
  344. End If
  345. m = m - 1
  346. s = 60
  347. End If
  348. s = s - 1
  349. End Sub
  350.