Essay
Problems - Correcting Code Errors
The following sample of code contains errors. Rewrite the incorrect statements to correct all errors.
Private Sub btnCalc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalc.Click
' calculates and displays the total amount owed for purchasing hats
' user enters number of hats and price per hat
' all hats are on sale for 25% off the price
Dim dblNumHats As Integer
Dim decHatPrice As Decimal
Dim decDiscount As Double
Dim decTotal As Decimal
' assign number of hats and price to variables
Integer.TryPurse(txtNumHats.Text, intNumHats)
Decimal.TryParse(txtHatPrice, decHatPrice)
' calculate and display the total amount owed
decDiscount = decHatPrice * dblRATE
decTotal = (intNumHats + decHatPrice) - decDiscount
Total.Text = decTotal.ToString(C2)
End Sub
Correct Answer:

Verified
Dim intNumHats As Integer
Const dblRATE...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
Const dblRATE...
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q11: A variable declared in the Declaration section
Q13: The strFirstName and strLastName variables contain the
Q16: A local gym needs an application to
Q31: Every numeric data type in Visual Basic
Q33: The _ of a variable determines where
Q34: Case-Based Critical Thinking Questions Case 1 -
Q41: The ControlChars.NewLine constant instructs the computer to
Q46: Spaces are allowed in variable names.
Q50: Instead of storing data in the properties
Q52: Data types and classes are not related