Beruflich Dokumente
Kultur Dokumente
/ 120 + / 10 + / 10 = / 140 = %
NAME: ___________________________
PART A: MULTIPLE CHOICE (50 x 1 MARKS)
__2) Which of the following events are activated in order to use Ascii codes for keys?
a) KeyDown b) KeyPress c) Load d) KeyUp
__3) Which of the following shows the proper order of mathematical operations followed by Visual
Basic?
a) brackets, powers, mult and div, add and subt.
b) powers, mult and div, add and subt, brackets.
c) powers, brackets, mult and div, add and subt.
d) mult and div, add and subt, brackets, powers.
__4) Which of the following statements would result in an error if typed as code?
a) Dim myArray(-4 to 5) As Integer
b) Dim x@ As Integer
c) Dim a_REALLY_sIlLyName3 As Double
d) Dim z As booleAn
__5) Which of the following Timer properties control moving a Timer around the form during run
time?
a) Left property b) Interval property
c) Top property d) None
__6) Which of the options below is not a standard Visual Basic data type?
a) currency b) strings c) whole numbers d) percentages
__9) Of the following objects, which does NOT respond directly to events initiated by
the user?
a) textbox b) timer c) command button
If condition Then
… statements
End If
a) executes the statements between the Then and the End If.
b) executes the statements following the End If.
c) does not execute any statements at all.
d) executes both the statement between the Then and the End If and the
statements following.
__16) To use more than one condition in an If-Then statement, you should join the
conditions with:
a) an And or Or b) &
c) + d) a True or False
__19) To calculate a cumulative sum you might see code that looks like…
a) T=T+x b) C=C+1 c) T+x=T d) C+1=C
__22) To have a For loop that executes 61 times, it would look like…
a) For x = -30 to 30 b) For x = -5 to 55
c) For x = 0 to 61 d) For x = 1 to 62
For x = 50 to 100
a) 0 b) 1 c) 41 d) 2
__29) Which two words should you type at the top of your code to insure that all spelling mistakes and
undeclared variables are caught?
a) Option Implicit
b) Check Spelling
c) Dim Explicit
d) Option Explicit
__30) In which of the following events would you see the expression “VBKey7”?
a) KeyDown
b) KeyPress
c) KeyAscii
d) KeyUp
__31) A variable declared with Global keyword in the general declarations sections of a
code module
a) is available only within the code module
b) is available to every procedure throughout the project
c) is a syntax error d) is always of the default type
__35) If you know before a loop begins, how many times it should execute, use a
a) If…statement b) Select Case
c) For Next Loop d) Array
__37) The following are three parameters sent to the InputBox function:
a) the value of the function, its title, and a prompt
b) its title, a prompt, and a default value
c) a prompt, a default value, and a message box
d) an icon, a prompt, and a caption
__40) When you move the mouse cursor over an object, which event gets executed?
a) MouseOver
b) MouseMove
c) KeyPress
d) MouseDown
a) IsCentered b) Alignment
c) Left d) Right
__42) Using For…Loops are a great way to access objects that are in a:
a) Select Case statement b) Control Array
c) For-statements d) Dim statements
__44) To declare an array of 10 Strings with the name ALIST use the declaration
a) General ALIST(1 to 10) As String
b) Dim ALIST(1 to 10) As Srting
c) Dim ALIST(0 to 10) As String
d) Dim ALIST(1 to 10) As String
__46) The BEST variable name for a counter that counts how many times the number
“5” shows up in a list would be:
a) theVariableWhichCountsHowManyFives
b) fIvEcOuNt c) counter d) fiveCounter
__47) To move an object closer to the bottom of the form, which of the following
properties / commands would we NOT use?
a) Move b) Top c) Left d) the object name
__48) When a Timer is first put on a form, its Name & Interval properties are:
a) tmr1, 1000 b) Timer, 0 c) Timer1, 1000 d) Timer1, 0
__49) Which of the following is not a way to run a Visual Basic program?
a) Select Run from the Visual Basic menu bar, then select Start
b) Press the function key, F5
c) Click the start button from the Visual Basic toolbar
d) Type Start from the keyboard
__50) The files that make up a Visual Basic project are listed in the
a) Properties window b) toolbar
c) Toolbox d) Project window
Dim x as Integer
x=x/x
__80) There are 12 letters in the last name of your computer science teacher this year.
Fill in the blank with the term(s) that best fit the sentence.
81) The “number” that refers to the “slot” in an array is called an ______________.
82) The method / function which takes an ascii code is the _________ method.
83) To clear a list box, use the _________ property.
84) You declare variables whose values must be available to more than one form in a
_________________.
85) To see if x is divisible by y, you test the condition: if…______________.
86) To set up a loop that generates values of x from 10 to 75, use the statement
____________________ to begin.
87) Decimals are represented by the ______________ data type.
88) Find the length of a string with the _______ function.
89) The __________ function converts a string to all uppercase characters.
90) Often the name of a constant is written with ________________.
PART D: ERROR CHECKING (10 x 1 MARKS)
91) Consider the following pieces of code. There are errors in the pieces of code.
Your job is to find them and state the reason for the error. There is a single
quote at the end of each line. Wherever you see an error, CIRCLE the line that
contains the error, and write a sentence (comment) or two after the single quote
that explains the error. Some lines may contain more than one error.
(2 x 5 MARKS)
a)
Dim a As Integer '
Dim b As Integer '
cmdGo_Click() '
a=a/a '
'
b=x–5 '
'
For c = 1 to x '
'
1-c=b '
'
Next x '
'
End Sub '
b)
Dim myArray(4 to MAX) As String '
Const MAX = 50 '
Dim z As Integer '
cmdGo_Click()
myArray(3) = “Bob” '
z=0 '
temp = myArray(3) '
if z = 1 '
z=0 '
End If '
End Sub
PART E: LONG ANSWER
You will be given two long answer questions. For each question make sure to read the
instructions carefully and remember that you are writing code as if you were using V.B., which means
that all english comments are to be handled accordingly as they would in V.B.
92) You are to complete code for ONLY A CLICK EVENT, whose main purpose is to look after a
Mastercard statement for a customer. When the user clicks the command button you are to do
the following: (10 MARKS)
Have an input box CONTINUALLY come up 10 TIMES asking the user if they
would like to make a purchase. They would then enter an amount.
i. Add the amount to a running total (starts off at 0), which will be their current
balance, which will always be displayed on a label called lblBalance.
ii. If the purchase has a negative amount, then assume that the
customer is making a payment on the balance, so that amount would
be subtracted from the balance, and then have the lblBalance updated
accordingly.
The credit card has a MAXIMUM limit of $5000. If the balance ever happens to
exceed that limit then have a message box come up conveying that information to the
customer and do not allow any more purchases, only payments.
If the user ever types in 0 for a purchase in the input box then that is your cue to end
the program.
You are to declare all variables, constants and ANY OTHER THINGS YOU NEED within the
event and if you think you need other things to help improve your mark then do whatever you
have to do to do that.
cmdCreditCard_Click()
End Sub
93) You are to write code for a function called “Numbers,” which does the following when it’s
called: (10 MARKS)
You are to declare all variables, constants and ANY OTHER THINGS YOU NEED within the
event and if you think you need other things to help improve your mark then do whatever you
have to do to do that.
End Sub