Chapter 5 and 6 Visual Basic Exam

Computer 4

1. A Boolean expression
is used when declaring a variable.
evaluates to either True or False
is a type of procedure that returns a numerical value

2. The Else portion of an If...Then...Else statement
is executed when the If condition is False
can contain only a single statement
is executed when the If condition is True


3. The MsgBox statement
displays a Visual Basic predefined dialog box with a message and an OK button
is used to provide information to the user
both of the above


4. What will the lblMessage Caption property be changed to after the following code is executed?

Dim intGrade As Integer

intGrade = 88
If intGrade >=70 Then lblMessage.Caption = "C"
ElseIf intGrade >= 80 Then lblMessage.Caption = "B"
Else lblMessage.Caption = "A" End If

A
B
C


5. Which statement correctly updates a counter?
identifier = identifier + 1
value = identifier + identifier
identifier = value + 1


6. Global variables
are accessible by every procedure in a form module
are declared using the keyword Public in the General section of the Code Editor window.
are declared in a procedure


Questions 7-9 refer to the following application:

Private Sub chkBold_Click()
Dim strDisplayWord As String
strDisplayWord = txtWord.Text
lblDisplayWord.Caption = strDisplayWord
If chkBold.Value = vbChecked Then
lblDisplayWord.Font.Bold = True
Else
lblDisplayWord.Font.Bold = False
End If
End Sub

Private Sub chkUnderline_Click()
Dim strDisplayWord As String
strDisplayWord = txtWord.Text
lblDisplayWord.Caption = strDisplayWord
If chkUnderline.Value = vbChecked Then
lblDisplayWord.Font.Underline = True
Else
lblDisplayWord.Font.Underline = False
End If
End Sub

Private Sub cmdOK_Click()
Unload Me
End Sub


7. What happens when the user clicks on the Underline check box when there was previously no check in it?
The word entered by the user is displayed as bold.
The word entered by the user is displayed as underlined
The word entered by the user is no longer displayed as bold


8. What happens when the user clicks on the Bold check box and then the Underline check box when neither check box previously had a check in them?
The word entered by the user is displayed only as bold
The word entered by the user is displayed only as underlined
The word entered by the user is displayed as bold and underlined


9. What happens when the user clicks on the Bold check box when there was previously a check in it?
The word entered by the user is displayed as bold
The word entered by the user is displayed as underlined
The word entered by the user is no longer displayed as bold


10. What is the value of strNewString after the following statement executes?

strNewString = LCase("LEttERs")


LETTERS
Letters
letters


11. What is the value of intStringPosition after the following statement executes?

intStringPosition = InStr(3, "string", "tri")


0
2
3


12. How many message boxes will be displayed as a result of the following code?

Dim intNum As Integer

For intNum = 10 To 1 Step -4

MsgBox intNum

Next intNum


10
3
4

13. What is the value of strNewString after the following statement executes?

strNewString = StrConv("faLL", vbProperCase)


FALL
Fall
fall


14. What is the value of strNewString after the following statement executes?

strNewString = Left("string", 3)


str
ing
rin

15. How many times is the loop executed in the following code?

intNumber = 0

Do

intNumber = intNumber + 1

Loop While intNumber <= 10


1
0
11


16. What is the value of strNewString after the following statement executes?

strNewString = Mid("string", 2, 3)


ng
ri
tri


17. What does the lblCompare label display after the following statement executes?

lblCompare.Caption = "string" Like "?trin?"


tring
True
False


18. What is the value of intCount after the following code has executed?

Dim intNum As Integer
Dim intCount As Integer

intCount = 0

For intNum = 2 To 6

If intNum > 4 Then

intCount = intNum + intCount

End If

Next intNum


20
15
11


19. What does the lblTest label display after the following statement executes?

lblTest.Caption = Chr(Asc("A"))


65
95
A


20. What is the value of intNum after the following code has executed?

Dim intNum As Integer
intNum = 10

Do While intNum Mod 2 = 0 And intNum > 0

intNum = intNum - 2

Loop


0
1
5

Name:

Score =

Application section