Professional Documents
Culture Documents
Assignment 1 - Patient Registration Form
Assignment 1 - Patient Registration Form
End Sub
' Call the validation function and if all data is valid, show success message
If ValidateForm() Then
Application.Exit()
End If
End Sub
MessageBox.Show("First Name must not be empty and should contain only letters.", "Validation
Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtFirstName.Focus()
Return False
End If
' Validate Last Name
MessageBox.Show("Last Name must not be empty and should contain only letters.", "Validation
Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtLastName.Focus()
Return False
End If
txtEmail.Focus()
Return False
End If
If Not Integer.TryParse(txtAge.Text, age) OrElse age <= 0 OrElse age >= 140 Then
txtAge.Focus()
Return False
End If
Return True
End Function
Return False
End If
Next
Return True
End Function
Try
Return True
Catch
Return False
End Try
End Function
End Class
Include a brief explanation of your program's functionality and how you approached data validation.
• User Interface:
• The form includes text boxes (TextBox) for input fields: First Name, Last Name, Email
Address, and Age.
• A submit button (Button) is included to trigger the validation process.
• Data Validation:
• First Name and Last Name: The input is checked to ensure it is not empty and contains
only letters. This is done using the IsAlphabetic function which iterates through each
character to ensure it is a letter.
• Email Address: The input is validated using the IsValidEmail function which tries to
create a MailAddress object. If it throws an exception, the email is invalid.
• Age: The input is checked to be a positive integer between 1 and 139 using
Integer.TryParse and conditional checks.
• Error Handling:
• Submission:
• If all fields pass validation, a success message is shown and the application exits.
INSTRUCTIONS FOR SUBMITTING YOUR WORK:
Provide your work in either a Word or PDF document in the following format:
Screenshots of the user interface, showing the inputs, error handling and feedback to the user, and
successful submission message
Screenshot of your Code segment showing implementation of data validation for each input
field, organization of code and comments
GRADING RUBRIC: