home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / VCR / SET.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-16  |  7.1 KB  |  213 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSetTime 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   2760
  6.    ClientLeft      =   780
  7.    ClientTop       =   1590
  8.    ClientWidth     =   5175
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   2760
  13.    ScaleWidth      =   5175
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.CommandButton cmdCancel 
  16.       Cancel          =   -1  'True
  17.       Caption         =   "Cancel"
  18.       Height          =   495
  19.       Left            =   3360
  20.       MaskColor       =   &H00000000&
  21.       TabIndex        =   7
  22.       Top             =   1200
  23.       Width           =   1215
  24.    End
  25.    Begin VB.CommandButton cmdOK 
  26.       Caption         =   "OK"
  27.       Default         =   -1  'True
  28.       Height          =   495
  29.       Left            =   3360
  30.       MaskColor       =   &H00000000&
  31.       TabIndex        =   6
  32.       Top             =   480
  33.       Width           =   1215
  34.    End
  35.    Begin VB.TextBox txtChannel 
  36.       Height          =   375
  37.       Left            =   1200
  38.       TabIndex        =   5
  39.       Text            =   "3"
  40.       ToolTipText     =   "Enter the channel to record"
  41.       Top             =   1920
  42.       Width           =   615
  43.    End
  44.    Begin VB.TextBox txtEnd 
  45.       Height          =   375
  46.       Left            =   1200
  47.       TabIndex        =   4
  48.       Text            =   "12:30 AM"
  49.       ToolTipText     =   "Enter the time to stop recording"
  50.       Top             =   1200
  51.       Width           =   1215
  52.    End
  53.    Begin VB.TextBox txtStart 
  54.       Height          =   375
  55.       Left            =   1200
  56.       TabIndex        =   3
  57.       Text            =   "12:00 AM"
  58.       ToolTipText     =   "Enter the time to start  recording"
  59.       Top             =   480
  60.       Width           =   1215
  61.    End
  62.    Begin VB.Label lblCaption 
  63.       Alignment       =   1  'Right Justify
  64.       Caption         =   "Channel"
  65.       Height          =   255
  66.       Index           =   2
  67.       Left            =   0
  68.       TabIndex        =   2
  69.       Top             =   2040
  70.       Width           =   1095
  71.    End
  72.    Begin VB.Label lblCaption 
  73.       Alignment       =   1  'Right Justify
  74.       Caption         =   "End Time"
  75.       Height          =   255
  76.       Index           =   1
  77.       Left            =   0
  78.       TabIndex        =   1
  79.       Top             =   1320
  80.       Width           =   1095
  81.    End
  82.    Begin VB.Label lblCaption 
  83.       Alignment       =   1  'Right Justify
  84.       Caption         =   "Start Time"
  85.       Height          =   255
  86.       Index           =   0
  87.       Left            =   0
  88.       TabIndex        =   0
  89.       Top             =   600
  90.       Width           =   1095
  91.    End
  92. Attribute VB_Name = "frmSetTime"
  93. Attribute VB_Base = "0{FF906415-E9E1-11CF-84BA-00AA00C007F0}"
  94. Attribute VB_GlobalNameSpace = False
  95. Attribute VB_Creatable = False
  96. Attribute VB_TemplateDerived = False
  97. Attribute VB_PredeclaredId = True
  98. Attribute VB_Exposed = False
  99. '**********************************************
  100. ' Purpose:  Form for getting user input to set
  101. '           the time and channel for recording.
  102. '           Part of the VCR sample application
  103. '**********************************************
  104. Option Explicit
  105. Private Sub cmdCancel_Click()
  106.     ' unload the form, release the reference
  107.     Unload Me
  108.     Set frmSetTime = Nothing
  109. End Sub
  110. Private Sub cmdOK_Click()
  111.     Dim intOK As Integer        'Return value
  112.     Dim intChannel As Integer   'Channel number
  113.     Dim strMsg As String        'Message text
  114.     ' Call the function to validate the entry
  115.     intOK = ValidateTime(txtStart.Text, txtStart)
  116.     ' If it wasn't valid, bail out here
  117.     If intOK = False Then Exit Sub
  118.         
  119.     ' Call the function to validate the entry
  120.     intOK = ValidateTime(txtEnd.Text, txtEnd)
  121.     ' If it wasn't valid, bail out here
  122.     If intOK = False Then Exit Sub
  123.     ' Read the value of the channel display
  124.     intChannel = Val(txtChannel)
  125.     ' If out of range, warn the user
  126.     If intChannel < 2 Or intChannel > 13 Then
  127.         strMsg = "Channel must be between 2 and 13!"
  128.         MsgBox strMsg, vbOKOnly, "Invalid Channel"
  129.         txtChannel.SetFocus
  130.         Exit Sub
  131.     End If
  132.     ' Set the properties of the Recorder class
  133.     Recorder.StartRecording = CVar(txtStart.Text)
  134.     Recorder.StopRecording = CVar(txtEnd.Text)
  135.     Recorder.Channel = intChannel
  136.         
  137.     ' unload the form, release the reference
  138.     Unload Me
  139.     Set frmSetTime = Nothing
  140. End Sub
  141. Private Sub Form_Load()
  142.     ' If the property of the class contains a
  143.     ' value, assign it to the TextBox
  144.     If Recorder.StartRecording <> Empty Then
  145.         txtStart.Text = Recorder.StartRecording
  146.     End If
  147.     If Recorder.StopRecording <> Empty Then
  148.         txtEnd.Text = Recorder.StopRecording
  149.     End If
  150.     txtChannel = Recorder.Channel
  151. End Sub
  152. '**********************************************
  153. ' Purpose:  Validates the time string entered by
  154. '           the user. If correct, it formats the
  155. '           string, if not, it displays a message.
  156. ' Inputs:   Time:   The string passed from a
  157. '                   text box.
  158. '           Field:  The name of the text box control.
  159. ' Returns:  True for a valid time, False if the
  160. '           string isn't a valid time.
  161. '**********************************************
  162. Function ValidateTime(Time As String, Field As Control) As Boolean
  163.     Dim strMsg As String    ' Message text
  164.     ' The IsDate function verifies a valid time
  165.     If IsDate(Time) Then
  166.         ' Format the string and return True
  167.         Field.Text = Format$(Time, "h:mm AM/PM")
  168.         ValidateTime = True
  169.     Else
  170.         ' Notify the user of the error
  171.         strMsg = "Please enter a valid time! "
  172.         strMsg = strMsg & "(Hour:Minute AM/PM)"
  173.         MsgBox strMsg, vbOKOnly, "Invalid Time"
  174.         ' Return focus to the textbox
  175.         Field.SetFocus
  176.         ' Return a value of False
  177.         ValidateTime = False
  178.     End If
  179. End Function
  180. Private Sub txtChannel_GotFocus()
  181.     ' Select the existing text
  182.     txtChannel.SelStart = 0
  183.     txtChannel.SelLength = Len(txtChannel.Text)
  184. End Sub
  185. Private Sub txtChannel_KeyPress(KeyAscii As Integer)
  186.     ' Use the IsNumeric function to make sure
  187.     ' only numbers can be entered
  188.     If Not IsNumeric(Chr(KeyAscii)) Then
  189.         ' Not a number, so set it to null
  190.         KeyAscii = 0
  191.     End If
  192. End Sub
  193. Private Sub txtEnd_GotFocus()
  194.     ' Select the existing text
  195.     txtEnd.SelStart = 0
  196.     txtEnd.SelLength = Len(txtEnd.Text)
  197. End Sub
  198. Private Sub txtEnd_LostFocus()
  199.     Dim intOK As Integer    ' Return value
  200.     ' Call the function to validate the entry
  201.     intOK = ValidateTime(txtEnd.Text, txtEnd)
  202. End Sub
  203. Private Sub txtStart_GotFocus()
  204.     ' Select the existing text
  205.     txtStart.SelStart = 0
  206.     txtStart.SelLength = Len(txtStart.Text)
  207. End Sub
  208. Private Sub txtStart_LostFocus()
  209.     Dim intOK As Integer    'Return value
  210.     ' Call the function to validate the entry
  211.     intOK = ValidateTime(txtStart.Text, txtStart)
  212. End Sub
  213.