home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / contdown / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-01-22  |  7.3 KB  |  249 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Count Down"
  6.    ClientHeight    =   2460
  7.    ClientLeft      =   3270
  8.    ClientTop       =   1635
  9.    ClientWidth     =   2055
  10.    ControlBox      =   0   'False
  11.    Height          =   2865
  12.    Icon            =   "FORM1.frx":0000
  13.    Left            =   3210
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    ScaleHeight     =   2460
  17.    ScaleWidth      =   2055
  18.    Top             =   1290
  19.    Width           =   2175
  20.    Begin VB.Timer Timer1 
  21.       Enabled         =   0   'False
  22.       Left            =   0
  23.       Top             =   3720
  24.    End
  25.    Begin VB.CommandButton Command4 
  26.       Caption         =   "Exit"
  27.       Height          =   375
  28.       Left            =   240
  29.       TabIndex        =   8
  30.       Top             =   2040
  31.       Width           =   1575
  32.    End
  33.    Begin VB.CommandButton Command3 
  34.       Caption         =   "Reset"
  35.       Enabled         =   0   'False
  36.       Height          =   375
  37.       Left            =   1440
  38.       TabIndex        =   7
  39.       Top             =   1560
  40.       Width           =   615
  41.    End
  42.    Begin VB.CommandButton Command2 
  43.       Caption         =   "Pause"
  44.       Height          =   375
  45.       Left            =   720
  46.       TabIndex        =   6
  47.       Top             =   1560
  48.       Width           =   615
  49.    End
  50.    Begin VB.CommandButton Command1 
  51.       Caption         =   "Start"
  52.       Height          =   375
  53.       Left            =   0
  54.       TabIndex        =   5
  55.       Top             =   1560
  56.       Width           =   615
  57.    End
  58.    Begin VB.TextBox Text3 
  59.       Alignment       =   2  'Center
  60.       Height          =   285
  61.       Left            =   1560
  62.       MultiLine       =   -1  'True
  63.       TabIndex        =   4
  64.       Top             =   240
  65.       Width           =   375
  66.    End
  67.    Begin VB.TextBox Text2 
  68.       Alignment       =   2  'Center
  69.       Height          =   285
  70.       Left            =   840
  71.       MultiLine       =   -1  'True
  72.       TabIndex        =   3
  73.       Top             =   240
  74.       Width           =   375
  75.    End
  76.    Begin VB.TextBox Text1 
  77.       Alignment       =   2  'Center
  78.       Height          =   285
  79.       Left            =   120
  80.       MultiLine       =   -1  'True
  81.       TabIndex        =   2
  82.       Top             =   240
  83.       Width           =   375
  84.    End
  85.    Begin VB.Label Label6 
  86.       Alignment       =   2  'Center
  87.       Caption         =   "Sec"
  88.       Height          =   255
  89.       Left            =   1560
  90.       TabIndex        =   12
  91.       Top             =   600
  92.       Width           =   375
  93.    End
  94.    Begin VB.Label Label5 
  95.       Alignment       =   2  'Center
  96.       Caption         =   "Min"
  97.       Height          =   255
  98.       Left            =   840
  99.       TabIndex        =   11
  100.       Top             =   600
  101.       Width           =   375
  102.    End
  103.    Begin VB.Label Label4 
  104.       Alignment       =   2  'Center
  105.       Caption         =   "Hrs"
  106.       Height          =   255
  107.       Left            =   120
  108.       TabIndex        =   10
  109.       Top             =   600
  110.       Width           =   375
  111.    End
  112.    Begin VB.Label Label3 
  113.       Alignment       =   2  'Center
  114.       Caption         =   "Time Remaining"
  115.       Height          =   255
  116.       Left            =   240
  117.       TabIndex        =   9
  118.       Top             =   840
  119.       Width           =   1575
  120.    End
  121.    Begin VB.Label Label2 
  122.       Alignment       =   2  'Center
  123.       Caption         =   "Select Time"
  124.       Height          =   255
  125.       Left            =   120
  126.       TabIndex        =   1
  127.       Top             =   0
  128.       Width           =   1695
  129.    End
  130.    Begin VB.Label Label1 
  131.       Alignment       =   2  'Center
  132.       BackColor       =   &H0000FFFF&
  133.       Caption         =   "00:00:00"
  134.       BeginProperty Font 
  135.          name            =   "Arial"
  136.          charset         =   1
  137.          weight          =   700
  138.          size            =   14.25
  139.          underline       =   0   'False
  140.          italic          =   0   'False
  141.          strikethrough   =   0   'False
  142.       EndProperty
  143.       ForeColor       =   &H000000FF&
  144.       Height          =   375
  145.       Left            =   240
  146.       TabIndex        =   0
  147.       Top             =   1080
  148.       Width           =   1575
  149.    End
  150. Attribute VB_Name = "Form1"
  151. Attribute VB_Creatable = False
  152. Attribute VB_Exposed = False
  153. 'Count down alarm program
  154. 'Written by Ed Hammond
  155. 'Ham & Ham Services
  156. 'hamham@harborside.com
  157. 'If you improve this program please send me a copy.
  158. 'Modified by Uddip Mitra
  159. 'Interstellar Software Cell
  160. 'indioman@hotmail.com
  161. 'Dimention the variables used in the program.
  162. Dim Hours As Integer
  163. Dim Minutes As Integer
  164. Dim Seconds As Integer
  165. Dim Time As Date
  166. Private Sub Mydisplay()
  167. 'This code is common to all three text boxes so I
  168. 'put it in it's own sub.
  169. 'Extract the numbers from the text boxes by using
  170. 'the Val() statement.
  171.     Hours = Val(Text1.Text)
  172.     Minutes = Val(Text2.Text)
  173.     Seconds = Val(Text3.Text)
  174. 'Convert variables to time format
  175.     Time = TimeSerial(Hours, Minutes, Seconds)
  176. 'Display the converted time variable in label 1
  177.     Label1.Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")
  178. End Sub
  179. Private Sub Command1_Click()
  180. 'Start button - turn on timer and disable reset
  181. 'button
  182.     Timer1.Enabled = True
  183.     Command3.Enabled = False
  184. End Sub
  185. Private Sub Command2_Click()
  186. 'Pause button - temporarily stop timer and enable
  187. 'reset button. You can restart countdown by clicking
  188. 'the start button. Or reset the time by clicking
  189. 'the reset button.
  190.     Timer1.Enabled = False
  191.     Command3.Enabled = True
  192. End Sub
  193. Private Sub Command3_Click()
  194. 'Reset button - reset all varibles and text boxes
  195. 'to nothting.
  196.     Hours = 0
  197.     Minutes = 0
  198.     Seconds = 0
  199.     Time = 0
  200.     Text1.Text = " "
  201.     Text2.Text = " "
  202.     Text3.Text = " "
  203.     Text1.SetFocus 'put curser in the hour text box
  204. End Sub
  205. Private Sub Command4_Click()
  206. 'Exit button - end program and clear varibles
  207.     End
  208. End Sub
  209. Private Sub Form_Load()
  210. 'Center form on screen.
  211. Form1.Top = (Screen.Height - Form1.Height) / 2
  212. Form1.Left = (Screen.Width - Form1.Width) / 2
  213. 'Set timer interval and varibles
  214.     Timer1.Interval = 1000
  215.     Hours = 0
  216.     Minutes = 0
  217.     Seconds = 0
  218.     Time = 0
  219. End Sub
  220. Private Sub Text1_Change()
  221. 'Call Mydisplay sub to display text box data
  222.     Mydisplay
  223. End Sub
  224. Private Sub Text2_Change()
  225. 'Call Mydisplay sub to display text box data
  226.     Mydisplay
  227. End Sub
  228. Private Sub Text3_Change()
  229. 'Call Mydisplay sub to display text box data
  230.     Mydisplay
  231. End Sub
  232. Private Sub Timer1_Timer()
  233.     'Count down loop
  234.     Timer1.Enabled = False
  235.     If (Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")) <> "00:00:00" Then 'Counter to continue loop until 0
  236.         Time = DateAdd("s", -1, Time)
  237.         Label1.Visible = False
  238.         Label1.Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")
  239.         Label1.Visible = True
  240.         Timer1.Enabled = True
  241.     Else
  242.         'Turn off timer, set off alarm, and enable reset.
  243.         Timer1.Enabled = False
  244.         Beep
  245.         Beep
  246.         Command3.Enabled = True
  247.     End If
  248. End Sub
  249.