home *** CD-ROM | disk | FTP | other *** search
/ The Mother of All Windows Books / CD-MOM.iso / cd_mom / utility / clocketc / att / settime.frm < prev    next >
Text File  |  1993-05-15  |  21KB  |  779 lines

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