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...
Local variables must be ________.
a. initialized when they are declared. b. initialized before their values are used in an expression. c. declared and initialized in two steps. d. declared at the top of the method.
Answer the following statements true (T) or false (F)
1. The amount of data that moves between the processor and memory at one time depends on the application. 2. Cache memory is a form of secondary storage. 3. The processor, often called the central processing unit (CPU), is the component that manipulates data. 4. A processor can do nothing without a program to provide control; whatever intelligence a computer has is derived from software, not hardware. 5. The processor manipulates data stored in memory under the control of a program stored in memory.
Which of the following methods would be used to disable the PRESET (_P_R_E_) and CLEAR (_C_L_R_) inputs to a clocked flip-flop in a circuit application where they are NOT used?
________-based e-mail is managed by a browser and enables access to e-mail from anywhere that has Internet access
Fill in the blank(s) with correct word