CIS3309: Component-Based Software Development Spring 2012 Quiz 2

Name:

1. Write a loop in VB to print the numbers 1 through 50.

2. Write a For loop in VB to print the numbers 10 through 0.

3. Write the necessary VB code to display a message in the Label lblMessage, “You worked overtime!” when the value of TextBox txtHoursWorked is more than 40 hours. Otherwise, display the message, “Work more!”

4. Evaluate the following conditions and write True or False to indicate what the result of the evaluation will be. Use the values x = 10, y = 15, and z = False to evaluate the conditions. a. (x + y) > ( x + x) ______b. (x > y) Or ((y – x) < x) ______c. (x + y) > (x + x) And Not(z) ______d. Not (y > x And z = False) ______5. Use the following code and write what will be displayed on the screen after all the code executes. Dim str As String = “Hello” Dim i As Integer = str.length - 1 Do While (i > 0) Dim ch As Char = str.Chars(i) i = i - 1 Debug.WriteLine(ch) Loop

Use the following code to answer questions 6 – 7. Dim count As Integer = 0 Do While (count < 30) If count = 10 Then Exit Do End If

count = count + 1 Loop

6. How many times will the following loop execute?

7. What is the value of the variable count after the loop executes?