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
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q39: Which of the following declares a StreamReader
Q40: Case 1 - Frames Unlimited
Frames Unlimited is
Q41: Write the code to declare a variable
Q42: Write a Structure statement that defines a
Q43: Write the statement that would write two
Q45: Describe two advantages to programmers of using
Q46: Write a Structure statement that defines a
Q47: What is the difference between an input
Q48: Write the code to declare a variable
Q49: The following sample of code contains errors.
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents