Hi im having even more problems i have run time error 9 Subscript out of range i can just use print #1 txtFullname.Tex t but i think this is wrong for my assignemt as i supposed ot use a collection and classes, also when command 2 butto is clicked it is supposed to go to the previous file yet it only changes the employee number , and leaves the rest of teh text boxes the same
[code=vb]
Public Employee As Object
Public EmployeeCollect ion As New Collection
Dim counter As Integer
Private Sub cmdExit_Click(I ndex As Integer)
Dim counter As Integer
counter = EmployeeCollect ion.Count
Open "c:\temp\Storag e.txt" For Append As #1
Seek #1, (counter + 1) * 100
Print #1, EmployeeCollect ion.Item(i).Ful lname ' error problem with this line
Print #1, EmployeeCollect ion.Item(i).Are a
Print #1, EmployeeCollect ion.Item(i).Pos tcode
Print #1, EmployeeCollect ion.Item(i).Add ress
Print #1, EmployeeCollect ion.Item(i).Con tactno
Print #1, EmployeeCollect ion.Item(i).Pos
Print #1, EmployeeCollect ion.Item(i).Sal ary
Close #1
End
End Sub
Private Sub cmdFirst_Click( Index As Integer)
txtEmployeeno.T ext = 1
txtFullname.Tex t = EmployeeCollect ion.Item(1).Ful lname
txtAddress.Text = EmployeeCollect ion.Item(1).Add ress
txtArea.Text = EmployeeCollect ion.Item(1).Are a
txtPostcode.Tex t = EmployeeCollect ion.Item(1).Pos tcode
txtContactno.Te xt = EmployeeCollect ion.Item(1).Con tactno
txtPos.Text = EmployeeCollect ion.Item(1).Pos
txtSalary.Text = EmployeeCollect ion.Item(1).Sal ary
End Sub
Private Sub cmdNew_Click(In dex As Integer)
Set Employee = New clsEmployee
Employee.Fullna me = txtFullname.Tex t
Employee.Addres s = txtAddress.Text
Employee.Area = txtArea.Text
Employee.Postco de = txtPostcode.Tex t
Employee.Contac tno = txtContactno.Te xt
Employee.Pos = txtPos.Text
Employee.Salary = txtSalary.Text
EmployeeCollect ion.Add clsEmployee
txtEmployeeno.T ext = EmployeeCollect ion.Count
Set Employee = Nothing
txtFullname.Tex t = " "
txtAddress.Text = " "
txtArea.Text = " "
txtPostcode.Tex t = " "
txtContactno.Te xt = " "
txtPos.Text = " "
txtSalary = " "
End Sub
Private Sub cmdP_Click()
counter = txtEmployeeno.T ext 'ALSO PROBLEM HERE
counter = counter - 1
txtEmployeeno = counter
txtFullname.Tex t = EmployeeCollect ion.Item(counte r).Fullname
txtAddress.Text = EmployeeCollect ion.Item(counte r).Address
txtArea.Text = EmployeeCollect ion.Item(counte r).Area
txtPostcode.Tex t = EmployeeCollect ion.Item(counte r).Postcode
txtContactno.Te xt = EmployeeCollect ion.Item(counte r).Contactno
txtPos.Text = EmployeeCollect ion.Item(counte r).Pos
txtSalary.Text = EmployeeCollect ion.Item(counte r).Salary
End Sub
Private Sub Form_Load()
Dim FileFullname As String
Dim FileArea As String
Dim FileAddress As String
Dim FilePostcode As String
Dim FileContactno As String
Dim FilePos As String
Dim FileSalary As String
Set EmployeeCollect ion = New Collection
Set Employee = New clsEmployee
Open "c:\temp\Storag e.txt" For Input As #1
While EOF(1) = False
Input #1, FileFullname
Input #1, FileAddress
Input #1, FileArea
Input #1, FilePostcode
Input #1, FileContactno
Input #1, FilePos
Input #1, FileSalary
Employee.Fullna me = FileFullname
Employee.Addres s = FileAddress
Employee.Area = FileArea
Employee.Postco de = FilePostcode
Employee.Contac tno = FileContactno
Employee.Pos = FilePos
Employee.Salary = FileSalary
EmployeeCollect ion.Add Employee
Wend
Close #1
txtEmployeeno.T ext = EmployeeCollect ion.Count
txtFullname.Tex t = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Fullname
txtAddress.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Address
txtArea.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Area
txtPostcode.Tex t = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Postcode
txtContactno.Te xt = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Contactno
txtPos.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Pos
txtSalary.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Salary
End Sub
[/code]
[code=vb]
Public Employee As Object
Public EmployeeCollect ion As New Collection
Dim counter As Integer
Private Sub cmdExit_Click(I ndex As Integer)
Dim counter As Integer
counter = EmployeeCollect ion.Count
Open "c:\temp\Storag e.txt" For Append As #1
Seek #1, (counter + 1) * 100
Print #1, EmployeeCollect ion.Item(i).Ful lname ' error problem with this line
Print #1, EmployeeCollect ion.Item(i).Are a
Print #1, EmployeeCollect ion.Item(i).Pos tcode
Print #1, EmployeeCollect ion.Item(i).Add ress
Print #1, EmployeeCollect ion.Item(i).Con tactno
Print #1, EmployeeCollect ion.Item(i).Pos
Print #1, EmployeeCollect ion.Item(i).Sal ary
Close #1
End
End Sub
Private Sub cmdFirst_Click( Index As Integer)
txtEmployeeno.T ext = 1
txtFullname.Tex t = EmployeeCollect ion.Item(1).Ful lname
txtAddress.Text = EmployeeCollect ion.Item(1).Add ress
txtArea.Text = EmployeeCollect ion.Item(1).Are a
txtPostcode.Tex t = EmployeeCollect ion.Item(1).Pos tcode
txtContactno.Te xt = EmployeeCollect ion.Item(1).Con tactno
txtPos.Text = EmployeeCollect ion.Item(1).Pos
txtSalary.Text = EmployeeCollect ion.Item(1).Sal ary
End Sub
Private Sub cmdNew_Click(In dex As Integer)
Set Employee = New clsEmployee
Employee.Fullna me = txtFullname.Tex t
Employee.Addres s = txtAddress.Text
Employee.Area = txtArea.Text
Employee.Postco de = txtPostcode.Tex t
Employee.Contac tno = txtContactno.Te xt
Employee.Pos = txtPos.Text
Employee.Salary = txtSalary.Text
EmployeeCollect ion.Add clsEmployee
txtEmployeeno.T ext = EmployeeCollect ion.Count
Set Employee = Nothing
txtFullname.Tex t = " "
txtAddress.Text = " "
txtArea.Text = " "
txtPostcode.Tex t = " "
txtContactno.Te xt = " "
txtPos.Text = " "
txtSalary = " "
End Sub
Private Sub cmdP_Click()
counter = txtEmployeeno.T ext 'ALSO PROBLEM HERE
counter = counter - 1
txtEmployeeno = counter
txtFullname.Tex t = EmployeeCollect ion.Item(counte r).Fullname
txtAddress.Text = EmployeeCollect ion.Item(counte r).Address
txtArea.Text = EmployeeCollect ion.Item(counte r).Area
txtPostcode.Tex t = EmployeeCollect ion.Item(counte r).Postcode
txtContactno.Te xt = EmployeeCollect ion.Item(counte r).Contactno
txtPos.Text = EmployeeCollect ion.Item(counte r).Pos
txtSalary.Text = EmployeeCollect ion.Item(counte r).Salary
End Sub
Private Sub Form_Load()
Dim FileFullname As String
Dim FileArea As String
Dim FileAddress As String
Dim FilePostcode As String
Dim FileContactno As String
Dim FilePos As String
Dim FileSalary As String
Set EmployeeCollect ion = New Collection
Set Employee = New clsEmployee
Open "c:\temp\Storag e.txt" For Input As #1
While EOF(1) = False
Input #1, FileFullname
Input #1, FileAddress
Input #1, FileArea
Input #1, FilePostcode
Input #1, FileContactno
Input #1, FilePos
Input #1, FileSalary
Employee.Fullna me = FileFullname
Employee.Addres s = FileAddress
Employee.Area = FileArea
Employee.Postco de = FilePostcode
Employee.Contac tno = FileContactno
Employee.Pos = FilePos
Employee.Salary = FileSalary
EmployeeCollect ion.Add Employee
Wend
Close #1
txtEmployeeno.T ext = EmployeeCollect ion.Count
txtFullname.Tex t = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Fullname
txtAddress.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Address
txtArea.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Area
txtPostcode.Tex t = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Postcode
txtContactno.Te xt = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Contactno
txtPos.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Pos
txtSalary.Text = EmployeeCollect ion.Item(Employ eeCollection.Co unt).Salary
End Sub
[/code]
Comment