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

Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
' verify that the user wants to exit the application
?
Dim dlgButton As DialogResult
dlgButton = MessageBox.Show("Do you want to exit?",
"Sample Program")
?
' if the No button was selected, don't close the form
If dlgButton = DialogResult.Yes Then
e.Cancel = True
End If
End Sub
?
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' fill combo box with values, then select default value
?
For intNumber As Integer From 0 Thru 10
cboNumbers.Add(intNumber.ToString)
Next intNumber
?
cboNumbers.SelectedItem = First
End Sub

What will be an ideal response?


Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing' verify that the user wants to exit the applicationDim dlgButton As DialogResultdlgButton = MessageBox.Show("Do you want to exit?","Sample Program",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1)' if the No button was selected, don't close the formIf dlgButton = DialogResult.No Thene.Cancel = TrueEnd IfEnd SubPrivate Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load' fill combo box with values, then select default valueFor intNumber As Integer = 0 To 10cboNumbers.Items.Add(intNumber.ToString)Next intNumbercboNumbers.SelectedIndex = 0End Sub

Computer Science & Information Technology

You might also like to view...

Case-Based Critical Thinking QuestionsCase 4-1Shay has come to ask you some questions about a few new projects he is developing because he knows that you know a lot about floating layouts, and he wants some guidance. A design that Shay created in the past was criticized because it did not leave enough room for the browser chrome. To make certain to avoid that problem this time, what width should she give to a design of a page created for a 1024 x 768 resolution?

A. 955 B. 1024 C. 1124 D. 1200

Computer Science & Information Technology

When you alter code to accommodate a style effect, leave an explanation in a(n) ____________________ so it's clear to you why the change was made when you look at the code later.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Chart styles and chart layouts affect the same chart elements and features

Indicate whether the statement is true or false.

Computer Science & Information Technology

Answer the following statement(s) true (T) or false (F)

1. Compared to the Crop Tool and warp grids, the Lens Correction dialog box has the added advantages of very precise measurements and other ways to correct errors. 2. After correcting keystone and angle errors, it is sometimes necessary to scale the image in order to regain any edges that were clipped by the correction. 3. The Remove Distortion Tool button corrects barrel and pincushion distortions. 4. The Move Grid Tool button is used to drag the grid lines to any position to help align edges within an image. 5. A positive value in the Vertical Perspective box in the Lens Correction dialog box brings the top of the picture closer, such as when shooting up from the base of a tall building.

Computer Science & Information Technology