Problems - Correcting Logic and Code ErrorsThe 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 codeDim strCodes() As String = {PT1, PT2, FT1, FT2, FT3}Dim dblRates() As Integer = {10.5, 12, 13.5, 14}Dim strSearchForCode As StringDim intSub As Integer' assign the code to a variabletxtCode.Text = strSearchForCode' search the strCodes array for the pay code' continue searching until the end of the array' or the pay code is foundDo Until intSub > strCodes.Length OrElsestrSearchForCode = strCodes(intSub)intSub = intSub + 1Loop' determine whether the pay code was foundIf intSub < strCodes.Length ThenlblRate.Text = dblRates(1).ToString("C0")ElseMessageBox.Show("Invalid Pay Code","Employee Pay Application",MessageBoxButtons.OK,MessageBoxIcon.Information)End IftxtCode.Focus()End Sub
What will be an ideal response?
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 Double = {10.5, 12, 13.5, 14, 14.5}
Dim strSearchForCode As String
Dim intSub As Integer
' assign the code to a variable
strSearchForCode = txtCode.Text
' 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 < strCodes.Length Then
lblRate.Text = dblRates(intSub).ToString("C0")
Else
MessageBox.Show("Invalid Pay Code",
"Employee Pay Application",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
txtCode.Focus()
End Sub
You might also like to view...
What do the initially empty stacks stack1and stack2“look like” after the following sequence of operations?
What will be an ideal response?
Case-Based Critical Thinking QuestionsCase 5-1Ethan would like to minimize his efforts in the development of his Web site. Kyra is ready to help him apply a variety of background properties.Ethan decides to have a background image that is repeated horizontally at the top of his page. What value does Kyra indicate he must use with the background-repeat property?
A. no-repeat B. repeat-x C. repeat-y D. repeat