I am having a hard time why my code does not write to a file.![]()
Code:Private Sub btnEnter_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnEnter.Click Dim values As String() = GetTextBoxValues() Dim record As New GradeBookDataCollector() Me.SetTextBoxValues(GetTextBoxValues) If values(TextBoxIndices.txtFirstName) <> "" Then Try Dim strFirstName As String = _ values(TextBoxIndices.txtFirstName) If strFirstName <> "" Then record.strFirstName = values(TextBoxIndices.txtFirstName) record.strLastName = values(TextBoxIndices.txtLastName) record.strCourseName = values(ComboBoxIndices.cboCourseName) record.strStudentId = values(TextBoxIndices.txtStudentId) record.strGrade = values(ComboBoxIndices.cboGrade) fileWriter.WriteLine( _ record.strFirstName.ToString & "," & record.strLastName.ToString & "," & _ record.strStudentId.ToString & "," & record.strCourseName.ToString & "," & _ record.strGrade.ToString) Else MessageBox.Show("Invalid First Name", "Error", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End If Catch ex As IOException MessageBox.Show("Error Writing to File", "Error", _ MessageBoxButtons.OK, MessageBoxIcon.Error) Catch ex As FormatException MessageBox.Show("Invalid Format", "Error", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End If Me.SetTextBoxValues(GetTextBoxValues) Me.ClearFormDataEntryBoxes() End Sub




Reply With Quote