So i got the "read from file" code correct but im wondering how exactly i can get everything I need to be written to the file. More info in the last comment i have posted at the bottom.
Here is the visual design.
Code:Public Class GradeCalculator Private Sub calculateButton_Click(sender As System.Object, e As System.EventArgs) Handles calculateButton.Click 'declare variables and constants Const EXAM1WV As Double = 0.2 Const EXAM2WV As Double = 0.3 Const LAB2WV As Double = 0.05 Const LAB3WV As Double = 0.1 Const LAB4WV As Double = 0.1 Const LAB5WV As Double = 0.1 Const FINALWV As Double = 0.15 Dim lab2 As Double Dim lab3 As Double Dim lab4 As Double Dim lab5 As Double Dim exam1 As Double Dim exam2 As Double Dim finalProject As Double Dim total As Double Dim totalWv As Double Dim endTotal As Double If lab2CheckBox.Checked = True Then lab2 = Val(lab2TextBox.Text) / 100 * LAB2WV total += lab2 totalWv += LAB2WV End If If lab3CheckBox.Checked = True Then lab3 = Val(lab3TextBox.Text) / 100 * LAB3WV total += lab3 totalWv += LAB3WV End If If lab4CheckBox.Checked = True Then lab4 = Val(lab4TextBox.Text) / 100 * LAB4WV total += lab4 totalWv += LAB4WV End If If lab5CheckBox.Checked = True Then lab5 = Val(lab5TextBox.Text) / 100 * LAB5WV total += lab5 totalWv += LAB5WV End If If exam1CheckBox.Checked = True Then exam1 = Val(exam1TextBox.Text) / 100 * EXAM1WV total += exam1 totalWv += EXAM1WV End If If exam2CheckBox.Checked = True Then exam2 = Val(exam2TextBox.Text) / 100 * EXAM2WV total += exam2 totalWv += EXAM2WV End If If finalCheckBox.Checked = True Then finalProject = Val(finalTextBox.Text) / 100 * FINALWV total += finalProject totalWv += FINALWV End If endTotal = total / totalWv percentageLabel.Text = String.Format("{0:P}", endTotal) End Sub Private fileName As String = "test3.txt" Private Sub writeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles writeButton.Click If percentageLabel.Text = String.Empty Then MessageBox.Show("Please enter the Grades to write.", "Enter Grade", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Else 'create the StreamWriter object Dim output = New StreamWriter(fileName, True) 'write to file the grade output.WriteLine("For the following graded items:" & ControlChars.NewLine) 'close the file output.Close() 'tell user that the information was written to file MessageBox.Show("The grades have been succesfully written to file", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information) 'make it possible to read readButton.Visible = True displayTextBox.Visible = True End If End Sub Private Sub readButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles readButton.Click Try 'variable to store info read from file Dim line As String = "" 'create the StreamReader object Dim input = New StreamReader(fileName) 'make do while loop Do While (input.EndOfStream() = False) line &= input.ReadLine() line &= ControlChars.NewLine Loop 'close the file that has been read input.Close() 'display what is stored in line variable in the read text box displayTextBox.Text = line 'if file does not exist, inform user to first write to file Catch ex As Exception MessageBox.Show("File does not exist...please first write to file.", "File does not exist", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try clearButton.Visible = True End Sub Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click displayTextBox.Text = String.Empty End Sub End Class End Class




Reply With Quote