Essay
The following sample of code contains errors. Rewrite the incorrect statements to correct all errors.
-Private Sub btnDisplay_Click(ByVal sender As Object,ByVal e As System.EventArgs)Handles btnDisplay.Click
' display the contents of the students.txt file
' declare variables
Dim inFile As IO.StreamWriter
Dim strStudent As String
' clear previous students from the Students box
lblStudents.Text = String.Empty
' determine whether the file exists
If IO.Exists("students.txt")= True Then
' open the file for input
inFile = IO.File.ReadText("students.txt")
' process loop instructions until end of file
Do Until inFile.Peek <> -1
' read a student line
strStudent = inFile.ReadLine
' display the student
lblStudents.Text = lblStudents.Text &
strStudent & ControlChars.NewLine
Loop
' close the file
Me.Close()
Else
MessageBox.Show("File not found","Students",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
End Sub
Correct Answer:

Verified
Private Sub btnDisplay_Click(ByVal sende...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q20: After opening a file for input,you can
Q21: Which of the following declares a StreamReader
Q22: You can use the Strings.Space method to
Q23: A file to which information is written
Q24: The following sample of code contains errors.
Q26: The members of a structure can be
Q27: Files to which information is written are
Q28: Describe two advantages to programmers of using
Q29: Write the statement that would write two
Q30: Which of the following statements will write