VERSION 5.00
Begin VB.Form frmRecordButtons1 
   ClientHeight    =   2865
   ClientLeft      =   60
   ClientTop       =   375
   ClientWidth     =   5025
   LinkTopic       =   "Form7"
   ScaleHeight     =   2865
   ScaleWidth      =   5025
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdPrev 
      Caption         =   "<"
      Height          =   315
      Left            =   2520
      TabIndex        =   1
      Top             =   2340
      Width           =   735
   End
   Begin VB.CommandButton cmdNext 
      Caption         =   ">"
      Height          =   315
      Left            =   3420
      TabIndex        =   0
      Top             =   2340
      Width           =   735
   End
   Begin VB.Label lblNumRecords 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   780
      TabIndex        =   9
      Top             =   2340
      Width           =   1635
   End
   Begin VB.Label Label1 
      Caption         =   "ID"
      Height          =   255
      Left            =   840
      TabIndex        =   8
      Top             =   660
      Width           =   1695
   End
   Begin VB.Label lblID 
      BackColor       =   &H80000009&
      Height          =   315
      Left            =   2520
      TabIndex        =   7
      Top             =   600
      Width           =   1575
   End
   Begin VB.Label Label3 
      Caption         =   "Name"
      Height          =   255
      Left            =   840
      TabIndex        =   6
      Top             =   1140
      Width           =   1575
   End
   Begin VB.Label lblName 
      BackColor       =   &H80000009&
      Height          =   315
      Left            =   2520
      TabIndex        =   5
      Top             =   1080
      Width           =   1575
   End
   Begin VB.Label Label5 
      Caption         =   "Telephone Number"
      Height          =   375
      Left            =   840
      TabIndex        =   4
      Top             =   1620
      Width           =   1575
   End
   Begin VB.Label lblTelNum 
      BackColor       =   &H80000009&
      Height          =   315
      Left            =   2520
      TabIndex        =   3
      Top             =   1560
      Width           =   1575
   End
   Begin VB.Label Label7 
      Alignment       =   2  'Center
      Caption         =   "View Records"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   0
      TabIndex        =   2
      Top             =   0
      Width           =   4995
   End
End
Attribute VB_Name = "frmRecordButtons1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
    Dim fileName As String
    Dim telNum As Long ' variable for holding the telephone number
    Dim firstname As String ' variable for holding the name
    Dim id As Integer ' variable for holding the id
    Dim currRecordNum As Integer  ' for keeping track of the current record
    Dim numRecords As Integer  ' the total number of records in the file

Private Sub Form_Load()
    currRecordNum = -1
    fileName = App.Path & "\record.txt"  ' specify file name.
    
    Open fileName For Input As #1 'Open file.
    
    ' loop and get values from the file.
    Do While (Not EOF(1))
        Input #1, id, firstname, telNum  'read data from file into variables.
        numRecords = numRecords + 1 ' get total number of records in file
    Loop
    
    Close   'Close all open files 
    
    ' check to see if there are any records in the file before enabling the button
    If (numRecords > 0) Then
        cmdNext.Enabled = True
    End If
    'disable the prev button to start with
    cmdPrev.Enabled = False
    
End Sub

Private Sub cmdNext_Click()
    Dim i As Integer
    Open fileName For Input As #1 'Open file.
    
    ' loop and get values from the file.
    For i = 0 To currRecordNum + 1
         Input #1, id, firstname, telNum  'read data from file into variables.
    Next
        
    Close   'Close all open files 
        
    currRecordNum = i - 1 ' set current record number
        
    lblID = id 'display id in the label
    lblName = firstname 'display name in the label
    lblTelNum = telNum 'display telephone number in the label

    ' display message in label saying which record is being displayed
    lblNumRecords = "Record " & currRecordNum + 1 & " of " & numRecords
               
    cmdPrev.Enabled = True  'enable the previous button
    
    ' if we are on the last record already
    If (currRecordNum = numRecords - 1) Then
        cmdNext.Enabled = False  ' disable the next button
    End If
End Sub

Private Sub cmdPrev_Click()
    Dim i As Integer
        
    Open fileName For Input As #1 'Open file.
    
    ' loop and get values from the file.
    For i = 0 To currRecordNum - 1
         Input #1, id, firstname, telNum  'read data from file into variables.
    Next
    currRecordNum = i - 1  ' set current record number
    
    Close   'Close all open files 
        
    lblID = id 'display id in the label
    lblName = firstname 'display name in the label
    lblTelNum = telNum 'display telephone number in the label
        
    ' display message in label saying which record is being displayed
    lblNumRecords = "Record " & currRecordNum + 1 & " of " & numRecords
             
    cmdNext.Enabled = True  'enable the previous button
    
    ' if we are on the last record already
    If (currRecordNum = 0) Then
        cmdPrev.Enabled = False  ' disable the next button
    End If
End Sub

