Examlex

Solved

The Following Sample of Code Contains Errors

question 25

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


Definitions:

Former Soviet Union

The group of republics that formed the Union of Soviet Socialist Republics (USSR), which existed from 1922 until its dissolution in 1991.

Reside

To live in a particular place.

Ecological Theory

A theoretical framework in the social and biological sciences that explores how organisms interact with each other and with their environments.

Ethnic Group

A population or group characterized by a shared cultural heritage or lineage.

Related Questions