VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A rolodex for keeping track of employee's records. acts like a miniature database.

by Brandon (46 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 22nd May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A rolodex for keeping track of employee's records. acts like a miniature database.

API Declarations


Private Type Employee
Name As String
Department As String
Phone As String
Email As String
End Type
Private IndexCount As Integer
Private EmployeeArray(1 To 100) As Employee



Rate A rolodex for keeping track of employee's records. acts like a miniature database.



'4 labels, 4 text boxes, 3 command buttons, common dialog
'control from Project, Components, apply the Microsoft Common
'Dialog Controls 6.0, apply and put control on the form.
'be sure to give the controls the names I've used in my code
'and for the labels:  Employee Name, Email, Department, and Phone.
'Also you will need to create a text file with extension .txt, in 
'notepad either from your hard drive or from another file location
'For sample data to be read from your input file you could use
'the following input.  Note you must enter the data EXACTLY how I do
'or you will get a runtime error.
'Example of input data in text file:

"John Smith", "Math", "[email protected]", "456-8989"
"Wally Rice", "English", "[email protected]", "340-8989"
"Linda Cooke", "Science", "[email protected]", "435-9090"

'************Main Program*********
'Program:  A sample view employee
'          records.
'Date: May 10, 2001
'*********************************
Private Sub cmdNextRecord_Click()
'view next record
IndexCount = IndexCount + 1
If EmployeeArray(IndexCount).Name = vbNullString Then
    MsgBox "You are at the last record", vbInformation, "Last Record"
    IndexCount = IndexCount - 1
Else
    Call PrintRecords
End If
End Sub

Private Sub cmdPrevious_Click()
'scroll to previous record
If IndexCount <= 1 Then
    MsgBox "You are on the first record", vbInformation, "First Record"
Else
    IndexCount = IndexCount - 1
    Call PrintRecords
End If
End Sub

Private Sub cmdReadFile_Click()
Dim udtName, udtDept, udtEmail, udtPhone As String
'get input from file
CommonDialog1.ShowOpen 'show all files
Open CommonDialog1.FileName For Input As #1
IndexCount = 1 'initialize for first record in array
Do While Not EOF(1)
'get data from text file
    Input #1, udtName, udtDept, udtEmail, udtPhone
    EmployeeArray(IndexCount).Name = udtName
    EmployeeArray(IndexCount).Department = udtDept
    EmployeeArray(IndexCount).Email = udtEmail
    EmployeeArray(IndexCount).Phone = udtPhone
    IndexCount = IndexCount + 1 'increment counter
Loop
Close #1 'close input file
IndexCount = 1 'reset counter
Call PrintRecords 'procedure call
cmdPrevious.Enabled = True 'enable controls
cmdNextRecord.Enabled = True
End Sub
Private Sub PrintRecords()
'print array records
txtEmpName.Text = EmployeeArray(IndexCount).Name
txtDepartment.Text = EmployeeArray(IndexCount).Department
txtEmail.Text = EmployeeArray(IndexCount).Email
txtPhone.Text = EmployeeArray(IndexCount).Phone
End Sub


Download this snippet    Add to My Saved Code

A rolodex for keeping track of employee's records. acts like a miniature database. Comments

No comments have been posted about A rolodex for keeping track of employee's records. acts like a miniature database.. Why not be the first to post a comment about A rolodex for keeping track of employee's records. acts like a miniature database..

Post your comment

Subject:
Message:
0/1000 characters