Name: ______

Quiz Three

Choose Two questions to answer. Only first two answers will be graded.

You may cross out the answer to avoid grading. Assume there is no syntax or logic error in the codes. The ToString method converts a value to string value.

1.  Determine the value of intTotal displayed in the message box once the following codes are executed (10 points). What will be the number of iterations of the loop (the number of times the loop will execute the codes inside of the loop)? Explain (40 points).

Dim intCounter As Integer = 0

Dim intTotal As Integer = 0

Do While intCounter < 5

intCounter = intCounter + 2

intTotal = intTotal + 10

Loop

MsgBox(intTotal.ToString)

2.  Determine the value of intTotal displayed in the message box once the following codes are executed (10 points). What will be the number of iterations of the loop (the number of times the loop will execute the codes inside of the loop)? Explain (40 points).

Dim intCounter As Integer

Dim intTotal As Integer = 0

For intCounter = 1 To 5 Step 2

intTotal = intTotal + 10

Next intCounter

MsgBox(intTotal.ToString)

3.  Based the GUI with the input value and the codes below, determine the output of the program when it is executed (10 point). Explain how (40 points).

Private Sub btnFindOut_Click(……..) Handles btnFindOut.Click

Dim intCentimeter As Integer

Dim blnGoodToGo As Boolean = True

'Read Input Value

intCentimeter = Val(txtCentimeter.Text)

'Process and Output

Select Case intCentimeter

Case Is 10

If Not ( blnGoodToGo = True ) Then

MsgBox("It is shorter than 10 centimeters and good to go.")

Else

MsgBox("It is shorter than 10 centimeters and not good to go.")

End If

Case 1

If blnGoodToGo = True Then

MsgBox("It is 1 centimeter and good to go.")

Else

MsgBox("It is 1 centimeter and no good to go.")

End If

End Select

End Sub