Problems - Correcting Logic and Code Errors
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
' displays the pay rate associated with a pay code
Dim strCodes() As String = {PT1, PT2, FT1, FT2, FT3}
Dim dblRates() As Integer = {10.5, 12, 13.5, 14}
Dim strSearchForCode As String
Dim intSub As Integer
' assign the code to a variable
txtCode.Text = strSearchForCode
' search the strCodes array for the pay code
' continue searching until the end of the array
' or the pay code is found
Do Until intSub > strCodes.Length OrElse
strSearchForCode = strCodes(intSub)
intSub = intSub + 1
Loop
' determine whether the pay code was found
If intSub
lblRate.Text = dblRates(1).ToString("C0")
Else
MessageBox.Show("Invalid Pay Code",
"Employee Pay Application",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
txtCode.Focus()
End Sub
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q47: The following array is declared and initialized:
Dim
Q48: Write the statement to declare a twelve-row,two-column
Q49: Write the statement to declare a seven-element
Q50: Case-Based Critical Thinking Questions Case 1 -
Q51: Case-Based Critical Thinking Questions Case 1 -
Q54: Problems - Correcting Logic and Code Errors
Q56: Write the statements to traverse the strCategory
Q57: Write the statement that assigns the length
Q58: Write the statement to declare a four-element
Q60: The following array is declared and initialized:
Dim
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents