1. Suppose x, j and n are globally declared as integers and x initially has a value of 3. If one calls the function MyFunc with the statement j = MyFunc (x) and the following function exists:~ Function MyFunc (n As Integer)~ n=4~ Debug.Print x~ End Function~What number is printed in the Debug window?
a. 0
b. 1
c. 3
d. 4
ans-d
Choice d is correct. By default, arguments are passed by reference and therefore can be changed by a procedure. VBPG p. 169.
t01
s10
multmult
2. Which of the following describe valid ways to place a command button on an MDI form?
a. place the command button directly on the MDI form
b. draw a picture box on the MDI form, then draw the command button on the picture box
c. draw a frame on the MDI form, then draw the command button on the frame
d. no controls may be placed directly on an MDI form
ans-b
Only choice b is correct. MDI forms can contain only menu and picture box controls and custom controls that have an Align property. Therefore, one must place the command button on a picture box drawn on the MDI form. VBLR p. 365.
t01
s06
multmult
3. Which are true of passing a property to a DLL?
a. the property can be passed directly to the DLL by value
b. an intermediate value must be used to pass a property to a DLL by value
c. the property can be passed directly to the DLL by reference
d. an intermediate value must be used to pass a property to a DLL by reference
ans-ad
Only choices a and d are correct. To pass a property by reference to a DLL, one must first assign the property to a string variable. VBPG p. 569.
t01
s02
mult
4. Which of the following will NOT reduce the amount of stack space used by Visual Basic code?
a. using global variables instead of passing values as arguments to procedures
b. using the integer data type instead of the variant data type for local variables
c. replacing local variable-length strings with local fixed-length strings
d. declaring procedures with the Static keyword
ans-c
Choice c is correct. Local fixed-length string variables consume one byte on the stack for each character, while local variable-length strings always consume only four bytes on the stack per string. VBPG pp. 263-264.
t01
s08
mult
5. Which statement is true of implementing transaction processing with multiple databases?
a. transaction processing will function against all open databases at once
b. transaction processing will function against only the databases that are open and specified
c. one may roll back the transactions in one database without rolling back the pending transactions in all other open databases
d. there is no limit on the number of transactions one may have pending
ans-a
Choice a is correct. Transaction operations are functionally global once one's application starts. Therefore, transaction processing will function against all open databases at once. VBPFB2 p. 107.
t01
s03
mult
6. Suppose procedure A contains error handling code containing the statement Resume Next and procedure B contains no error handling code. What will happen if procedure A calls procedure B and procedure B contains an error?
a. the error handling code in procedure A is invoked and the line in procedure A following the call to procedure B is executed
b. the error handling code in procedure A is invoked and the line in procedure B following the error is executed
c. the error handling code in procedure A is invoked and the call to procedure B is re-executed
d. the error is not trapped since procedure B contains no error handling code
ans-a
Choice a is correct. If an error occurs, Visual Basic searches backward through the pending procedures. If Resume Next is encountered, the statement executed is in the procedure where the error-handling procedure is found. VBPG pp. 244-245.
t01
s07
mult
7. Suppose a command string is sent from a destination application to a source application in a DDE conversation using the LinkExecute method. What event is triggered in the active form in the source application?
a. LinkExecute
b. LinkReceive
c. LinkOpen
d. LinkProcess
ans-a
Choice a is correct. The command string is passed as an argument to the source application when the destination application executes the LinkExecute method. The LinkExecute event is triggered in the source application. VBLR pp. 318-319.
t01
s02
mult
8. Suppose MySub is declared as follows:~ Sub MySub (j$)~How would one pass the Caption property of Label1 to this procedure?
a. MySub (Label1.Caption)
b. MySub Label1.Caption
c. Call MySub (Label1.Caption)
d. the value of Label1.Caption must be assigned an intermediate string value and then passed
ans-a
Choice a is correct. Label1.Caption must be enclosed in parentheses before it is passed so that an expression is passed rather than a data type. VBPG p. 169. If Call is used, an extra set of parentheses is required. VBLR p. 55. A parameter type mismatch occurs if Label1.Caption is not passed correctly.
t02
s04
mult
9. Suppose a label control is dragged over an image control and then dropped. Which events are generated?
a. the image control's DragDrop event, only
b. the label control's DragDrop event, only
c. both the label's DragDrop event and the image control's DragDrop event
d. neither the label's DragDrop event nor the image control's DragDrop event
ans-a
Choice a is correct. The DragDrop event occurs for a control as a result of a source control being dragged over the control and releasing the mouse button. VBLR p. 151.
t02
s04
mult
10. Suppose the focus changes from Text1 on Form1 to Text1 on Form2. Which event occurs first?
a. the GotFocus event for Text1 on Form2
b. the LostFocus event for Text1 on Form1
c. the GotFocus event for Form2
d. the LostFocus event for Form1
ans-b
Choice b is correct. The LostFocus event for Text1 on Form1 occurs before any other event listed. VBLR p. 357.
t02
s01
mult
11. Which statement should one place in the general declarations section of a form to require that variables be declared before they are used?
a. Variables Explicit
b. Option Explicit
c. this is the default situation
d. this is not possible
ans-b
Choice b is correct. The Option Explicit statement causes Visual Basic to require that variables be declared before they are used. This helps one avoid mistyping the name of an existing variable. Option Explicit can be automatically included by setting the Require Variable Declaration option to Yes under the Environment menu. VBLR p. 423.
t02
s09
mult
12. Which syntax could one use to remove a picture from an image control named Image1?
a. Image1.Clear
b. Image1.Clr
c. Image1.Picture = LoadPicture("")
d. Image1.Picture = ""
ans-c
Choice c is correct. LoadPicture can be used to remove a picture at run time without replacing it with another picture. VBPG p. 325. The Cls method may also be used to clear an image control. VBLR p. 79.
t02
s11
mult
13. In order to specify a Help file for an application:
a. one may specify the Help file using the Project Options dialog, only
b. one may specify the Help file at run time, only
c. one may specify the Help file either at run time or by using the Project Options dialog
d. one may specify the Help file neither at run time nor by using the Project Options dialog
ans-c
Choice c is correct. One may set the Help file at design time by selecting Options, Project and then entering the Help file. To set the Help file at run time, set the App.HelpFile property to the name of the Help file. VBPFB1, Help Compiler Guide, p. 158.
t02
s10
mult
14. Which statement is true regarding loading MDI parent and child forms?
a. if an MDI form is loaded, its child forms are automatically loaded
b. a child form cannot be specified as an application's startup form
c. if a child form is loaded, its parent form (the MDI form) is automatically loaded but not displayed
d. if a child form is loaded, its parent form (the MDI form) is automatically loaded and displayed
ans-d
Choice d is correct. Loading an MDI form does not cause its child forms to be loaded. However, loading a child form causes its parent form to load and be displayed. A child form may be specified as the startup form. VBPG. p. 303.
t03
s05
mult
15. Which syntax is used to populate a combo box?
a. control.AddItem item [, index]
b. control.AddNew item
c. control.Add item [, index]
d. control.ListAdd item index
ans-a
Choice a is correct. The AddItem method is used to add items to a combo box. Specifying an index is optional. VBLR p.27.