![]() ![]() Private Sub SaveFileDialog1_FileOk(sender As Object, e As ) Handles sfdSave.FileOk Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click 'Clears all content currently within text boxes Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click 'If no filename exists, will prompt save dialog box and prompt user to save as MessageBox.Show("Email Address cannot be blank", "Invalid Entry") MessageBox.Show("Extension must be positive", "Invalid Entry") MessageBox.Show("Extension must be numeric", "Invalid Entry") MessageBox.Show("Extension cannot be blank", "Invalid Entry")ĮlseIf Not (Integer.TryParse(txtExtension.Text, intTryParse)) Then MessageBox.Show("Telephone number must be numeric", "Invalid Entry") MessageBox.Show("Telephone number cannot be blank", "Invalid Entry") MessageBox.Show("Employee department cannot be blank", "Invalid Entry") MessageBox.Show("Employee number must be positive", "Invalid Entry") MessageBox.Show("Employee number must be numeric", "Invalid Entry")ĮlseIf CStr(txtEmployeeNumber.Text) < 0 Then MessageBox.Show("Employee number cannot be blank", "Invalid Entry")ĮlseIf Not (Integer.TryParse(txtEmployeeNumber.Text, intTryParse)) Then MessageBox.Show("Last name cannot be blank", "Invalid Entry") MessageBox.Show("Middle name cannot be blank", "Invalid Entry") MessageBox.Show("First name cannot be blank", "Invalid Entry") Private Sub btnSaveRecord_Click(sender As Object, e As EventArgs) Handles btnSaveRecord.Click ![]() Please select 'Save As' Option.", "Error In Saving") MessageBox.Show("Employee saved successfully.", "Success") SavedEmployeeFile = File.AppendText(fileName) 'Throws error if file could Not be created SavedEmployeeFile.WriteLine(txtEmailAddress.Text) SavedEmployeeFile.WriteLine(txtExtension.Text) SavedEmployeeFile.WriteLine(txtTelephone.Text) SavedEmployeeFile.WriteLine(ComboBo圎mpDepartment.Text) SavedEmployeeFile.WriteLine(txtLastName.Text) SavedEmployeeFile.WriteLine(txtMiddleName.Text) SavedEmployeeFile.WriteLine(txtFirstName.Text) 'writes information entered by user into file SavedEmployeeFile = File.CreateText(fileName) ![]() 'Adds the department options to the combo box dropdown listĬomboBo圎("Accounting")ĬomboBo圎("Administration")ĬomboBo圎("Marketing") Private Sub frmEmployeeData_Load(sender As Object, e As EventArgs) Handles MyBase.Load Here is my code for the form: Option Strict Off I am very new to visual basic and am unsure of why this is not working. The issue I am experiencing is that it will run the TRY and ignore the CATCH, allowing invalid data to pass and save to the file. I am working on an employee database and am having issues with my TRY\CATCH for saving records as it pertains to exception handling. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
May 2023
Categories |