Open the SwatTheBugs Solution file contained in the ClearlyVB2012\Chap09\SwatTheBugs Solution folder. The application should calculate an 8% bonus on a salesperson's sales.
However, a salesperson having a sales code of 5 reeives an additional $150 bonus when the sales are at least $10,000; othewise, he or she receives an additional $125 bonus. Open the Code Editor window and study the code.
Start and then test the application.
Notice that the code is not working correctly. Locate and correct any errors. Close the Code Editor window and then close the solution.
Public Class frmMain
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' display bonus
Const decRATE As Decimal = 0.08
Const decADD_BONUS1 = 150
Const decADD_BONUS2 = 125
Dim intCode As Integer
Dim decSales As Decimal
Dim decBonus As Decimal
Integer.TryParse(txtCode.Text, intCode)
Decimal.TryParse(txtSales.Text, decSales)
' calculate bonus
decBonus = decSales * decRATE
' add additional bonus
If intCode = 5 AndAlso decSales >= 10000 Then
decBonus = decBonus + decADD_BONUS1
Else
decBonus = decBonus + decADD_BONUS2
End If