Problems: Correcting Logic and Code ErrorsThe following sample of code contains errors. Rewrite the incorrect statements to correct all errors.

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
   ' Displays all records or a record for a specific year
    If radAll.Checked Then
        WinnersTableAdapter(OscarsDataSet.Winners)
    Or
        If txtYear.Text.Trim = String.Empty Then
           MessageBox.Show("Please enter the year.", "Oscar Winners",
                            MessageBoxButtons.OK, MessageBoxInformation)
        Else
           Dim intYear As Integer
           Integer.TryParse(txtYear.Text.Trim, intYear)
           WinnersTableAdapter.FillByYear(OscarsDataSet.Winners, intYear)
        End If
End Sub

What will be an ideal response?

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click   ' Displays all records or a record for a specific year   If radAll.Checked Then        WinnersTableAdapter.Fill(OscarsDataSet.Winners)   Else        If txtYear.Text.Trim = String.Empty Then           MessageBox.Show("Please enter the year.", "Oscar Winners",                            MessageBoxButtons.OK, MessageBoxInformation)        Else           Dim intYear As Integer           Integer.TryParse(txtYear.Text.Trim, intYear)           WinnersTableAdapter.FillByYear(OscarsDataSet.Winners, intYear)        End If   End IfEnd Sub

Computer Science & Information Technology

You might also like to view...

Microsoft offers a free online service called ________

A) Windows Live SkyDrive B) Windows SkyDive C) Skype D) File Storage Area

Computer Science & Information Technology

The is-a relationship represents.

a. Composition. b. Inheritance. c. Information Hiding. d. A friend.

Computer Science & Information Technology