home *** CD-ROM | disk | FTP | other *** search
/ PC-Test Pro / PCTESTPRO.iso / clocks / attall / entp / settime.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-30  |  20.2 KB  |  724 lines

  1. VERSION 2.00
  2. Begin Form SetTimeForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Set Time"
  6.    ClientHeight    =   1305
  7.    ClientLeft      =   2970
  8.    ClientTop       =   3315
  9.    ClientWidth     =   3570
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   1740
  13.    Left            =   2895
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   1305
  18.    ScaleWidth      =   3570
  19.    Top             =   2955
  20.    Width           =   3720
  21.    Begin SSCommand Command3D1 
  22.       Height          =   465
  23.       Left            =   165
  24.       Picture         =   SETTIME.FRX:0000
  25.       TabIndex        =   18
  26.       Top             =   720
  27.       Width           =   540
  28.    End
  29.    Begin CommandButton Command1 
  30.       Cancel          =   -1  'True
  31.       Caption         =   "Cancel"
  32.       Height          =   360
  33.       Index           =   1
  34.       Left            =   2265
  35.       TabIndex        =   20
  36.       Top             =   765
  37.       Width           =   1155
  38.    End
  39.    Begin CommandButton Command1 
  40.       Caption         =   "Set"
  41.       Default         =   -1  'True
  42.       Height          =   360
  43.       Index           =   0
  44.       Left            =   885
  45.       TabIndex        =   19
  46.       Top             =   765
  47.       Width           =   1155
  48.    End
  49.    Begin PictureBox SpinButton 
  50.       AutoSize        =   -1  'True
  51.       BackColor       =   &H00C0C0C0&
  52.       Height          =   360
  53.       Index           =   1
  54.       Left            =   3255
  55.       ScaleHeight     =   330
  56.       ScaleWidth      =   135
  57.       TabIndex        =   17
  58.       TabStop         =   0   'False
  59.       Top             =   240
  60.       Width           =   165
  61.    End
  62.    Begin SSFrame Frame3D1 
  63.       ForeColor       =   &H00000000&
  64.       Height          =   444
  65.       Index           =   1
  66.       Left            =   1830
  67.       TabIndex        =   11
  68.       Top             =   156
  69.       Width           =   1395
  70.       Begin TextBox tYear 
  71.          BackColor       =   &H00C0C0C0&
  72.          BorderStyle     =   0  'None
  73.          Height          =   225
  74.          Left            =   780
  75.          MaxLength       =   4
  76.          TabIndex        =   14
  77.          Tag             =   "y"
  78.          Text            =   "1955"
  79.          Top             =   150
  80.          Width           =   480
  81.       End
  82.       Begin TextBox tDay 
  83.          BackColor       =   &H00C0C0C0&
  84.          BorderStyle     =   0  'None
  85.          Height          =   225
  86.          Left            =   450
  87.          MaxLength       =   2
  88.          TabIndex        =   13
  89.          Tag             =   "d"
  90.          Text            =   "17"
  91.          Top             =   150
  92.          Width           =   240
  93.       End
  94.       Begin TextBox tMonth 
  95.          Alignment       =   1  'Right Justify
  96.          BackColor       =   &H00C0C0C0&
  97.          BorderStyle     =   0  'None
  98.          Height          =   225
  99.          Left            =   120
  100.          MaxLength       =   2
  101.          TabIndex        =   12
  102.          Tag             =   "n"
  103.          Text            =   "09"
  104.          Top             =   150
  105.          Width           =   240
  106.       End
  107.       Begin Label Label1 
  108.          Alignment       =   2  'Center
  109.          BackColor       =   &H00C0C0C0&
  110.          Caption         =   "/"
  111.          Height          =   225
  112.          Index           =   3
  113.          Left            =   690
  114.          TabIndex        =   16
  115.          Top             =   150
  116.          Width           =   105
  117.       End
  118.       Begin Label Label1 
  119.          Alignment       =   2  'Center
  120.          BackColor       =   &H00C0C0C0&
  121.          Caption         =   "/"
  122.          Height          =   225
  123.          Index           =   2
  124.          Left            =   345
  125.          TabIndex        =   15
  126.          Top             =   150
  127.          Width           =   105
  128.       End
  129.    End
  130.    Begin PictureBox SpinButton 
  131.       AutoSize        =   -1  'True
  132.       BackColor       =   &H00C0C0C0&
  133.       Height          =   360
  134.       Index           =   0
  135.       Left            =   1590
  136.       ScaleHeight     =   330
  137.       ScaleWidth      =   135
  138.       TabIndex        =   7
  139.       TabStop         =   0   'False
  140.       Top             =   240
  141.       Width           =   165
  142.    End
  143.    Begin PictureBox N 
  144.       AutoSize        =   -1  'True
  145.       Height          =   360
  146.       Left            =   2970
  147.       Picture         =   SETTIME.FRX:016A
  148.       ScaleHeight     =   330
  149.       ScaleWidth      =   135
  150.       TabIndex        =   6
  151.       TabStop         =   0   'False
  152.       Top             =   1995
  153.       Visible         =   0   'False
  154.       Width           =   165
  155.    End
  156.    Begin PictureBox U 
  157.       AutoSize        =   -1  'True
  158.       Height          =   360
  159.       Left            =   3180
  160.       Picture         =   SETTIME.FRX:0294
  161.       ScaleHeight     =   330
  162.       ScaleWidth      =   135
  163.       TabIndex        =   5
  164.       TabStop         =   0   'False
  165.       Top             =   1980
  166.       Visible         =   0   'False
  167.       Width           =   165
  168.    End
  169.    Begin PictureBox D 
  170.       AutoSize        =   -1  'True
  171.       Height          =   360
  172.       Left            =   3405
  173.       Picture         =   SETTIME.FRX:03BE
  174.       ScaleHeight     =   330
  175.       ScaleWidth      =   135
  176.       TabIndex        =   0
  177.       TabStop         =   0   'False
  178.       Top             =   1980
  179.       Visible         =   0   'False
  180.       Width           =   165
  181.    End
  182.    Begin SSFrame Frame3D1 
  183.       ForeColor       =   &H00000000&
  184.       Height          =   444
  185.       Index           =   0
  186.       Left            =   168
  187.       TabIndex        =   8
  188.       Top             =   156
  189.       Width           =   1392
  190.       Begin TextBox tHour 
  191.          Alignment       =   1  'Right Justify
  192.          BackColor       =   &H00C0C0C0&
  193.          BorderStyle     =   0  'None
  194.          Height          =   225
  195.          Left            =   120
  196.          MaxLength       =   2
  197.          MultiLine       =   -1  'True
  198.          TabIndex        =   1
  199.          Tag             =   "h"
  200.          Text            =   "12"
  201.          Top             =   150
  202.          Width           =   240
  203.       End
  204.       Begin TextBox tMinute 
  205.          BackColor       =   &H00C0C0C0&
  206.          BorderStyle     =   0  'None
  207.          Height          =   225
  208.          Left            =   456
  209.          MaxLength       =   2
  210.          TabIndex        =   2
  211.          Tag             =   "m"
  212.          Text            =   "00"
  213.          Top             =   150
  214.          Width           =   240
  215.       End
  216.       Begin TextBox tAMPM 
  217.          BackColor       =   &H00C0C0C0&
  218.          BorderStyle     =   0  'None
  219.          Height          =   225
  220.          Left            =   1020
  221.          TabIndex        =   4
  222.          Tag             =   "a"
  223.          Text            =   "am"
  224.          Top             =   150
  225.          Width           =   285
  226.       End
  227.       Begin TextBox tSecond 
  228.          BackColor       =   &H00C0C0C0&
  229.          BorderStyle     =   0  'None
  230.          Height          =   225
  231.          Left            =   780
  232.          MaxLength       =   2
  233.          TabIndex        =   3
  234.          Tag             =   "s"
  235.          Text            =   "00"
  236.          Top             =   150
  237.          Width           =   240
  238.       End
  239.       Begin Label Label1 
  240.          Alignment       =   2  'Center
  241.          BackColor       =   &H00C0C0C0&
  242.          Caption         =   ":"
  243.          Height          =   225
  244.          Index           =   0
  245.          Left            =   345
  246.          TabIndex        =   10
  247.          Top             =   150
  248.          Width           =   105
  249.       End
  250.       Begin Label Label1 
  251.          Alignment       =   2  'Center
  252.          BackColor       =   &H00C0C0C0&
  253.          Caption         =   ":"
  254.          Height          =   225
  255.          Index           =   1
  256.          Left            =   675
  257.          TabIndex        =   9
  258.          Top             =   150
  259.          Width           =   105
  260.       End
  261.    End
  262. Option Explicit
  263. DefInt A-Z
  264. Dim LastY As Single
  265. Dim Active As String
  266. Dim LastDirection As String
  267. Dim tVal As Integer
  268. ' Jeffrey M. Richter's Spin Button Control from Windows 3: A Developer's Guide
  269. ' Adapted for Visual Basic by Costas Kitsos with Mr. Richter's kind permission
  270. ' Windows API functions used by the Spin Button Control
  271. Declare Function GetTickCount Lib "User" () As Long
  272. Declare Function GetAsyncKeyState Lib "User" (ByVal vKey As Integer) As Integer
  273. Sub Command1_Click (Index As Integer)
  274. If Index = 0 Then
  275.   Time = tHour.Text + ":" + tMinute.Text + ":" + tSecond.Text + UCase$(tAMPM.Text)
  276.   Date = tMonth.Text + "/" + tDay.Text + "/" + tYear.Text
  277.   LastTime = 0
  278.   LastHour = Val(Format$(Time, "hh"))
  279.   LastQuarter = Val(Format$(Time, "nn")) \ 15
  280.   Unload SetTimeForm
  281. End If
  282. If Index = 1 Then
  283.   LastTime = 0
  284.   Unload SetTimeForm
  285. End If
  286. End Sub
  287. Sub Command3D1_Click ()
  288. AtomicTimeWasSet = False
  289. Atomic.Show 1
  290. Unload Atomic
  291. If AtomicTimeWasSet Then
  292.    Unload SetTimeForm
  293. End If
  294. End Sub
  295. Sub FlipFlopTAMPM ()
  296.          If tAMPM.Text = "am" Then
  297.             tAMPM.Text = "pm"
  298.          Else
  299.             tAMPM.Text = "am"
  300.          End If
  301. End Sub
  302. Sub Form_GotFocus ()
  303.     tHour.SetFocus
  304.     DoEvents
  305. End Sub
  306. Sub Form_Load ()
  307. SetTimeForm.Left = Settings.Left + (Settings.Width / 2) - (SetTimeForm.Width / 2)
  308. SetTimeForm.Top = Settings.Top + (Settings.Height / 2) - (SetTimeForm.Height / 2)
  309. Dim Instant As Double
  310. Dim InitialHeight As Integer
  311.     InitialHeight = SpinButton(0).Height
  312.     SpinButton(0).Picture = N.Picture       'Set to the Normal Spin Button
  313.     SpinButton(0).Top = SpinButton(0).Top + (InitialHeight - SpinButton(0).Height) / 2
  314.     SpinButton(1).Picture = N.Picture       'Set to the Normal Spin Button
  315.     SpinButton(1).Top = SpinButton(1).Top + (InitialHeight - SpinButton(1).Height) / 2
  316.     Instant = Now
  317.     If Hour(Instant) = 0 Then
  318.        tHour.Text = "12"
  319.        tAMPM.Text = "am"
  320.     End If
  321.     If Hour(Instant) >= 1 And Hour(Instant) <= 11 Then
  322.        tHour.Text = Format$(Hour(Instant))
  323.        tAMPM.Text = "am"
  324.     End If
  325.     If Hour(Instant) = 12 Then
  326.        tHour.Text = Format$(Hour(Instant))
  327.        tAMPM.Text = "pm"
  328.     End If
  329.     If Hour(Instant) >= 13 And Hour(Instant) <= 23 Then
  330.        tHour.Text = Format$(Hour(Instant) - 12)
  331.        tAMPM.Text = "pm"
  332.     End If
  333.     tMinute.Text = Format$(Minute(Instant), "00")
  334.     tSecond.Text = Format$(Second(Instant), "00")
  335.     tMonth.Text = Format$(Month(Instant), "00")
  336.     tDay.Text = Format$(Day(Instant), "00")
  337.     tYear.Text = Format$(Year(Instant), "0000")
  338.     'SetTimeFOrm.Show
  339.     'DoEvents
  340. End Sub
  341. Sub MoveDown (c As Control)
  342. Dim CurVal As Integer
  343. CurVal% = Val(c.Text)
  344. Select Case c.Tag
  345.    Case "h"
  346.       If CurVal% = 12 Then
  347.          FlipFlopTAMPM
  348.       End If
  349.       If CurVal% = 1 Then
  350.          c.Text = "12"
  351.       Else
  352.          c.Text = Val(c.Text) - 1
  353.       End If
  354.    Case "m"
  355.       If CurVal% = 0 Then
  356.          c.Text = "59"
  357.       Else
  358.          c.Text = Format$(Val(c.Text) - 1, "00")
  359.       End If
  360.    Case "s"
  361.       If CurVal% = 0 Then
  362.          c.Text = "59"
  363.       Else
  364.          c.Text = Format$(Val(c.Text) - 1, "00")
  365.       End If
  366.    Case "a"
  367.       FlipFlopTAMPM
  368.    Case "n"
  369.       If CurVal% = 1 Then
  370.          c.Text = "12"
  371.       Else
  372.          c.Text = Format$(Val(c.Text) - 1, "00")
  373.       End If
  374.    Case "d"
  375.       If CurVal% = 1 Then
  376.          c.Text = "31"
  377.       Else
  378.          c.Text = Format$(Val(c.Text) - 1, "00")
  379.       End If
  380.    Case "y"
  381.       If CurVal% = 1 Then
  382.          c.Text = "2050"
  383.       Else
  384.          c.Text = Format$(Val(c.Text) - 1, "0000")
  385.       End If
  386. End Select
  387. 'c.Text = Val(c.Text) - 1
  388. End Sub
  389. Sub MoveUp (c As Control)
  390. Dim CurVal As Integer
  391. CurVal% = Val(c.Text)
  392. Select Case c.Tag
  393.    Case "h"
  394.       If CurVal% = 11 Then
  395.          FlipFlopTAMPM
  396.       End If
  397.       If CurVal% = 12 Then
  398.          c.Text = "1"
  399.       Else
  400.          c.Text = Val(c.Text) + 1
  401.       End If
  402.    Case "m"
  403.       If CurVal% = 59 Then
  404.          c.Text = "00"
  405.       Else
  406.          c.Text = Format$(Val(c.Text) + 1, "00")
  407.       End If
  408.    Case "s"
  409.       If CurVal% = 59 Then
  410.          c.Text = "00"
  411.       Else
  412.          c.Text = Format$(Val(c.Text) + 1, "00")
  413.       End If
  414.    Case "a"
  415.       FlipFlopTAMPM
  416.    Case "n"
  417.       If CurVal% = 12 Then
  418.          c.Text = "01"
  419.       Else
  420.          c.Text = Format$(Val(c.Text) + 1, "00")
  421.       End If
  422.    Case "d"
  423.       If CurVal% = 31 Then
  424.          c.Text = "01"
  425.       Else
  426.          c.Text = Format$(Val(c.Text) + 1, "00")
  427.       End If
  428.    Case "y"
  429.       If CurVal% = 2050 Then
  430.          c.Text = "1980"
  431.       Else
  432.          c.Text = Format$(Val(c.Text) + 1, "0000")
  433.       End If
  434. End Select
  435. End Sub
  436. Sub SpinButton_DblClick (Index As Integer)
  437. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  438.    tMonth.SetFocus
  439. End If
  440. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  441.    tHour.SetFocus
  442. End If
  443. If LastDirection$ = "u" Then
  444.    Select Case Active$
  445.      Case "n"
  446.         Call MoveUp(tMonth)
  447.      Case "d"
  448.         Call MoveUp(tDay)
  449.      Case "y"
  450.         Call MoveUp(tYear)
  451.      Case "h"
  452.         Call MoveUp(tHour)
  453.      Case "m"
  454.         Call MoveUp(tMinute)
  455.      Case "s"
  456.         Call MoveUp(tSecond)
  457.      Case "a"
  458.         Call MoveUp(tAMPM)
  459.    End Select
  460.    Select Case Active$
  461.      Case "n"
  462.         Call MoveDown(tMonth)
  463.      Case "d"
  464.         Call MoveDown(tDay)
  465.      Case "y"
  466.         Call MoveDown(tYear)
  467.      Case "h"
  468.         Call MoveDown(tHour)
  469.      Case "m"
  470.         Call MoveDown(tMinute)
  471.      Case "s"
  472.         Call MoveDown(tSecond)
  473.      Case "a"
  474.         Call MoveDown(tAMPM)
  475.    End Select
  476. End If
  477. SpinButton(Index).SetFocus
  478. End Sub
  479. Sub SpinButton_GotFocus (Index As Integer)
  480. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  481.    tMonth.SetFocus
  482.    Exit Sub
  483. End If
  484. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  485.    tHour.SetFocus
  486.    Exit Sub
  487. End If
  488.    Select Case Active$
  489.      Case "n"
  490.         tMonth.SetFocus
  491.      Case "d"
  492.         tDay.SetFocus
  493.      Case "y"
  494.         tYear.SetFocus
  495.      Case "h"
  496.         tHour.SetFocus
  497.      Case "m"
  498.         tMinute.SetFocus
  499.      Case "s"
  500.         tSecond.SetFocus
  501.      Case "a"
  502.         tAMPM.SetFocus
  503.    End Select
  504. End Sub
  505. Sub SpinButton_MouseDown (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  506. Const VK_LBUTTON = &H1
  507. Const TIME_DELAY = 180      ' Time delay between Spin Button Events
  508. Dim dwEvent As Long
  509. LastY = Y
  510. ' Make sure that the Spin Button Event occurs at least once
  511. dwEvent = GetTickCount() - TIME_DELAY
  512. SpinIt:
  513.    ' Do this while the user holds down the left mouse button
  514.    Do While (GetAsyncKeyState(VK_LBUTTON) And &H8000) = -32768
  515.         ' Break out of the loop if we haven't waited long enough
  516.         If dwEvent + TIME_DELAY > GetTickCount() Then GoTo Break:
  517.         ' If the user wants to increment the counter
  518.         If Y > (SpinButton(Index).Height \ 2) Then
  519.             SpinButton(Index).Picture = d.Picture  ' Set Picture to Up
  520.             If Index = 1 Then
  521.             Select Case Active$
  522.                Case "n"
  523.                    Call MoveDown(tMonth)
  524.                Case "d"
  525.                    Call MoveDown(tDay)
  526.                Case "y"
  527.                    Call MoveDown(tYear)
  528.             End Select
  529.             End If
  530.             If Index = 0 Then
  531.             Select Case Active$
  532.                Case "h"
  533.                    Call MoveDown(tHour)
  534.                Case "s"
  535.                    Call MoveDown(tSecond)
  536.                Case "m"
  537.                    Call MoveDown(tMinute)
  538.                Case "a"
  539.                    Call MoveDown(tAMPM)
  540.             End Select
  541.             End If
  542.             LastDirection$ = "d"
  543.         End If
  544.         ' If the user wants to decrement the counter
  545.         If Y < (SpinButton(Index).Height \ 2) Then
  546.             SpinButton(Index).Picture = u.Picture   ' Set Picture to Down
  547.             If Index = 1 Then
  548.             Select Case Active$
  549.                Case "n"
  550.                    Call MoveUp(tMonth)
  551.                Case "d"
  552.                    Call MoveUp(tDay)
  553.                Case "y"
  554.                    Call MoveUp(tYear)
  555.             End Select
  556.             End If
  557.             If Index = 0 Then
  558.             Select Case Active$
  559.                Case "h"
  560.                    Call MoveUp(tHour)
  561.                Case "s"
  562.                    Call MoveUp(tSecond)
  563.                Case "m"
  564.                    Call MoveUp(tMinute)
  565.                Case "a"
  566.                    Call MoveUp(tAMPM)
  567.             End Select
  568.             End If
  569.             LastDirection$ = "u"
  570.         End If
  571.         ' Save the last time the Spin Button was active
  572.         dwEvent = GetTickCount()
  573.     Loop
  574.     ' Set the Picture to Normal
  575.     SpinButton(Index).Picture = N.Picture
  576.     If Index = 1 Then
  577.     Select Case Active$
  578.        Case "n"
  579.           tMonth.SetFocus
  580.        Case "d"
  581.           tDay.SetFocus
  582.        Case "y"
  583.           tYear.SetFocus
  584.     End Select
  585.     End If
  586.     If Index = 0 Then
  587.     Select Case Active$
  588.        Case "h"
  589.           tHour.SetFocus
  590.        Case "m"
  591.           tMinute.SetFocus
  592.        Case "s"
  593.           tSecond.SetFocus
  594.        Case "a"
  595.           tAMPM.SetFocus
  596.     End Select
  597.     End If
  598.     DoEvents
  599.     Exit Sub
  600. Break:
  601.     GoTo SpinIt:
  602. End Sub
  603. Sub tAMPM_GotFocus ()
  604. tAMPM.SelStart = 0
  605. tAMPM.SelLength = 2
  606. Active$ = "a"
  607. End Sub
  608. Sub tAMPM_KeyPress (KeyAscii As Integer)
  609. If KeyAscii >= 32 Then
  610.    FlipFlopTAMPM
  611.    KeyAscii = 0
  612.    tAMPM.SelStart = 0
  613.    tAMPM.SelLength = 2
  614. End If
  615. End Sub
  616. Sub tAMPM_LostFocus ()
  617. If tAMPM.Text <> "am" And tAMPM.Text <> "pm" Then
  618.    tAMPM.Text = "am"
  619. End If
  620. End Sub
  621. Sub tDay_GotFocus ()
  622. tDay.SelStart = 0
  623. tDay.SelLength = 2
  624. Active$ = "d"
  625. End Sub
  626. Sub tDay_KeyPress (KeyAscii As Integer)
  627. If KeyAscii >= 32 Then
  628.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  629. End If
  630. End Sub
  631. Sub tDay_LostFocus ()
  632. tVal = Val(tDay.Text)
  633. If tVal < 1 Or tVal > 31 Then
  634.    tVal = 1
  635. End If
  636. tDay.Text = Format$(tVal, "00")
  637. End Sub
  638. Sub tHour_GotFocus ()
  639. tHour.SelStart = 0
  640. tHour.SelLength = 2
  641. Active$ = "h"
  642. End Sub
  643. Sub tHour_KeyPress (KeyAscii As Integer)
  644. If KeyAscii >= 32 Then
  645.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  646. End If
  647. End Sub
  648. Sub tHour_LostFocus ()
  649. tVal = Val(tHour.Text)
  650. If tVal < 1 Or tVal > 12 Then
  651.    tVal = 12
  652. End If
  653. tHour.Text = Format$(tVal, "0")
  654. End Sub
  655. Sub tMinute_GotFocus ()
  656. tMinute.SelStart = 0
  657. tMinute.SelLength = 2
  658. Active$ = "m"
  659. End Sub
  660. Sub tMinute_KeyPress (KeyAscii As Integer)
  661. If KeyAscii >= 32 Then
  662.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  663. End If
  664. End Sub
  665. Sub tMinute_LostFocus ()
  666. tVal = Val(tMinute.Text)
  667. If tVal <= 0 Or tVal > 59 Then
  668.    tVal = 0
  669. End If
  670. tMinute.Text = Format$(tVal, "00")
  671. End Sub
  672. Sub tMonth_GotFocus ()
  673. tMonth.SelStart = 0
  674. tMonth.SelLength = 2
  675. Active$ = "n"
  676. End Sub
  677. Sub tMonth_KeyPress (KeyAscii As Integer)
  678. If KeyAscii >= 32 Then
  679.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  680. End If
  681. End Sub
  682. Sub tMonth_LostFocus ()
  683. tVal = Val(tMonth.Text)
  684. If tVal < 1 Or tVal > 12 Then
  685.    tVal = 12
  686. End If
  687. tMonth.Text = Format$(tVal, "00")
  688. End Sub
  689. Sub tSecond_GotFocus ()
  690. tSecond.SelStart = 0
  691. tSecond.SelLength = 2
  692. Active$ = "s"
  693. End Sub
  694. Sub tSecond_KeyPress (KeyAscii As Integer)
  695. If KeyAscii >= 32 Then
  696.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  697. End If
  698. End Sub
  699. Sub tSecond_LostFocus ()
  700. tVal = Val(tSecond.Text)
  701. If tVal <= 0 Or tVal > 59 Then
  702.    tVal = 0
  703. End If
  704. tSecond.Text = Format$(tVal, "00")
  705. End Sub
  706. Sub tYear_GotFocus ()
  707. tYear.SelStart = 0
  708. tYear.SelLength = 4
  709. Active$ = "y"
  710. End Sub
  711. Sub tYear_KeyPress (KeyAscii As Integer)
  712. If KeyAscii >= 32 Then
  713.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  714. End If
  715. End Sub
  716. Sub tYear_LostFocus ()
  717. tVal = Val(tYear.Text)
  718. If tVal < 100 Then tVal = tVal + 1900
  719. If tVal < 1980 Or tVal > 2050 Then
  720.    tVal = 1980
  721. End If
  722. tYear.Text = Format$(tVal, "0000")
  723. End Sub
  724.