Currently my program fires out error messages when the user enters information outwith the boundaries. However for every valid entry these will be stored in the array and the entry outwith the boundaries will be listed as blank which I dont want. Id like the program to only store an entry in the array if all the criteria for the boundaries are met. Could anyone advise me how to do this?
Thanks
Dim Index As Integer = 0
Dim EmployeeRec(9) As EmployeeType
Private Sub add_bta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles add_bta.Click
If Val(employeeid_txt.Text) > 10 Or Val(employeeid_txt.Text) < 1 Then
MessageBox.Show("Employee Id Outwith Range 1 to 10 ", "Please re-enter", MessageBoxButtons.OK)
Else
EmployeeRec(Index).Employeeid = employeeid_txt.Text
End If
EmployeeRec(Index).Status = "Active"
If Len(firstname_txt.Text) > 15 Or Len(firstname_txt.Text) = 0 Then
MessageBox.Show("Firstname Outwith Range 1 to 15 ", "Please re-enter", MessageBoxButtons.OK)
Else
EmployeeRec(Index).Firstname = firstname_txt.Text
End If
If Len(surname_txt.Text) > 15 Or Len(surname_txt.Text) = 0 Then
MessageBox.Show("Surname Outwith Range 1 to 15 ", "Please re-enter", MessageBoxButtons.OK)
Else
EmployeeRec(Index).Surname = surname_txt.Text
End If
If Val(Age_txt.Text) > 100 Or Val(Age_txt.Text) < 16 Then
MessageBox.Show("Age Outwith Range 16 to 100 ", "Please re-enter", MessageBoxButtons.OK)
Else
EmployeeRec(Index).Details.Age = Age_txt.Text
End If
If Len(gender_txt.Text) > 6 Or Len(gender_txt.Text) < 4 Then
MessageBox.Show("Gender must be Male or Female ", "Please re-enter", MessageBoxButtons.OK)
Else
EmployeeRec(Index).Details.Gender = gender_txt.Text
End If
If Len(position_txt.Text) > 15 Or Len(position_txt.Text) = 0 Then
MessageBox.Show("Position Outwith Range 1 to 15 ", "Please re-enter", MessageBoxButtons.OK)
Else
EmployeeRec(Index).Position = position_txt.Text
End If
Index = Index + 1
End Sub