CIS 230 Practice Exam #2 (Ch. 5 - 7)

Part I

TRUE/FALSE

False 1 Common dialog controls may be moved to any location on the form and they may be resized.
False  2 Function procedures may or may not return a value.
False  3 Global variables are visible to all forms within a project and are declared using the keyword Static.

MULTIPLE CHOICE

 4 If a procedure will be needed in multiple forms in a project, the procedure should be written in a
  1. function procedure.
  2. standard code module.
  3. global variable.
  4. form module.
 5 Items can be added to a list during run time using the _________ method.
  1. AddList
  2. List
  3. ItemAdd
  4. AddItem
 6 What is the value of j after the code in the loop below is completed?
For j = 2 to 12 Step 3
           ‘Statements in loop
Next j
  1. 11
  2. 12
  3. 13
  4. 14
  5. 15

Part II

Write a code segment that performs the following tasks. Follow the precise directions and do not add prefixes to specified identifiers.

1. Write a for loop that iterates and causes the computer to beep exactly 15 times with an index variable named intCounter.

For intCounter = 1 To 15
     Beep
Next intCounter

2. Write a Do Until/Loop that iterates until the variable j reaches the value of 15. A counter statement that increments j by one should be contained inside of the loop. Assume that j is assigned the value of 0 before the first statement of the loop.

Do Until (j >= 15)
     j = j + 1
Loop

3. Fill in the VB code necessary to define a general subroutine named Whatever that triples its integer argument W and displays the result in a label named lblDisplay. The argument W is passed to Whatever by value.

Private Sub Whatever(ByVal W As Integer )
   
 W = 3 * W
     lblDisplay.Caption = W
End Sub

4. Write a single VB statement that extracts middle name ("Jacob") from the string literal "John Jacob Jingleheimerschmidt" and displays it in the label, lblName, using the Mid string function.

lblName.Caption = Mid("John Jacob Jingleheimerschmidt", 6, 5)

5. Write a bottom-checking (posttest) indeterminant loop that iterates until the user enters the string "enuff" into a text box named txtInput. The loop should make the computer beep on each iteration.

Do
     Beep
Loop Until (txtInput.Text = "enuff")

6. Write a complete private function named sngBonus that calculates and returns the amount of 10% salary bonus applied to an argument (the employee's salary) which is passed to the function by value. The parameter should be named sngSalary and its data type is Single.

Private Function sngBonus(ByVal sngSalary As Single) As Single
     sngBonus = 0.10 * sngSalary
End Function


CIS 230 Home PageExam Information