I need to add student name and grade to a file.
This is my section of code so far

Private Sub addStudentNameGrade_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addStudentNameGrade.Click
        Dim swrStreamWriter As IO.StreamWriter
        swrStreamWriter = IO.File.AppendText(path & "studentgrade.txt")
        swrStreamWriter.WriteLine(Me.textStudent.Text, " ", Me.textGrade.Text)
        'swrStreamWriter.WriteLine(Me.textGrade.Text)
        swrStreamWriter.Close()
    End Sub

I know the problem is with this line " swrStreamWriter.WriteLine(Me.textStudent.Text, " ", Me.textGrade.Text) " . I'm not sure how to show in the file "textStudent textGrade". Need to write, in a file student then grade on the same line, eg. " Brandon 70 "

Recommended Answers

All 2 Replies

You want to make both texts one string and write that to the file.

swrStreamWriter.WriteLine(Me.textStudent.Text + " " + Me.textGrade.Text)

Also research the VB.Net String Functions for further reading.

commented: again, a great help, thanks +2

cool thank you, I forgot about concatenation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.