CIS 230 Practice Exam #1 (Ch. 1 - 4)

Part I


 1 When creating a project in Visual Basic you should always begin by writing the Basic code.
 2 When you are designing the user interface and writing code you are in run time.
 3 After you have added a command button to a form you can change what is displayed on the form (inside the button) by changing the Caption property.
 4 Remark statements are not executable code.
 5 If a project runs without halting, you can be assured that the code was written without error.
 6 You write Visual Basic code statements during Design Time.


 7 Microsoft Windows uses GUI environment. GUI (pronounced gooey) stands for
  1. Geographical User Interchange.
  2. Graphical User Interface.
  3. Geometrical Upper Intelligence.
  4. Grammatical User Incorporation.
 8 Each Visual Basic project consists of at least two files,
  1. the project file and a form file called a form module.
  2. the project file and a standard code module.
  3. one file with the extension .VBP and one file with the .FRM extension.
  4. Both answers a and c are correct.
 9 Assume that you want to add a control to a form, in which window in the Visual Basic environment would you get a command button?
  1. The Toolbox
  2. The Project window
  3. The Properties window
  4. The Form window
 10 Remarks, or comments, that programmers add to their code in order to make the program more readable and understandable
  1. are executable code.
  2. are for program documentation only.
  3. are not considered "executable".
  4. Both answers b and c are correct.
 11 Which of the following are coding conventions required by the textbook?
  1. Remarks must be included in the general declarations section.
  2. Every event procedure must include remarks, which describe the actions performed.
  3. All statements between the Sub and End Sub must be indented.
  4. All objects (except labels not referred to in code) must be named with a three-character prefix which identifies the object type.
  5. All of the above.
12 The code that is used in a sub procedure to stop execution of a program is:
  1. Exit
  2. Halt
  3. End
  4. End Sub


 13 You can select multiple controls by clicking on the first control and then hold the Ctrl key and click on each of the other controls in the group.
 14 Setting the Cancel property of a command button to True will allow the user to press Enter to select the button.
 15 If you have several option buttons that were created by double-clicking, you can make them belong to a frame by dragging them on top of the frame.
 16 The statement: txtItem.SetFocus, will place the insertion point in the text box called txtItem.
 17 You can make a label appear when the user pauses the mouse pointer over a control by setting the control’s ToolTipText property.
 18 The ToolTipText property of a control must be set to "Centered" so that text displaying on the control will appear centered.
 19 When a checkbox is checked, the value property may be tested for a value of True.


 20 Your project will allow the user to choose the background color for the form. You will offer them five choices. You should use
  1. check boxes.
  2. text boxes.
  3. option buttons.
  4. name boxes.
 21 Image controls hold a graphic, which is assigned to the
  1. frame property.
  2. text property.
  3. caption property.
  4. picture property.
 22 Setting the TabIndex of a control to 0 will
  1. cause the control to appear to the right of the other controls.
  2. make the control Visible.
  3. align the control to the left of the other controls.
  4. set the focus on this control when the program begins running.
 23 Small labels that pop up when the user pauses the mouse pointer over a control on the form are created by
  1. using the SetFocus method.
  2. changing the object’s Text property to True.
  3. setting the object’s ToolTipText property.
  4. setting the object’s Value property to True.
 24 To load an icon into an image control, change the control’s _______ property.
  1. image
  2. picture
  3. graphic
  4. icon
 25 Which of the following property settings should be used on an object named txtUserInput in order to make the insertion point appear in the object when the form first appears?
  1. SetFocus = True
  2. TabStop = SetFocus
  3. TabIndex = True
  4. TabIndex = 0
 26 To determine whether an option button is currently selected, check its _______ property.
  1. Value
  2. Enabled
  3. Selected
  4. Visible
 27 Which of the following is not a valid value for the Shape property of a Shape control?
  1. rectangle
  2. circle
  3. oval
  4. box
 28 When you are using the line control you should remember that all lines
  1. must be horizontal.
  2. must be vertical.
  3. can be horizontal or vertical.
  4. can be drawn in any direction.
 29 The naming prefix for a label control is __________ .
  1. lab
  2. lbl
  3. lbe
  4. l


 29 Data whose value may not be changed during the execution of a project is referred to a constant.
 30 If you are declaring a variable that will be used in calculations, you may use the currency datatype.
 31 Numeric constants may contain only the digits ( 0 - 9 ), a decimal point, and a sign ( + or - ) at the left side.
 32 A variable must be declared with a Dim statement before it is used.
 33 A variable that is declared with the Dim statement in a local procedure is initialized to zero each time the procedure occurs.
 34 Local variables can be used in any procedure in the module as long as they are declared somewhere in the project.
 35 The Val function can be used to eliminate the problems encountered when the user does not enter a value into a field.


 36 Which of the following is not a valid variable data type?
  1. Integer
  2. Real
  3. Currency
  4. String
 37 If a declaration statement does not specify a datatype, it will default to
  1. boolean.
  2. string.
  3. variant.
  4. variable.
 38 The datatype that is most commonly used for decimal fractions is
  1. currency.
  2. variant.
  3. integer.
  4. long.
 39 The length of identifiers is limited to
  1. 1 to 8 characters.
  2. 1 to 25 characters.
  3. 1 to 40 characters.
  4. 1 to 255 characters.
 40 The statement to declare a local variable called Index that will store whole numbers is:
  1. Dim whlIndex as Whole
  2. Dim strIndex as String
  3. Dim Integer as intIndex
  4. Dim intIndex as Integer
 41 Which of the following is NOT a rule for naming identifiers?
  1. Identifiers for constants must use an underscore between words.
  2. Identifiers can not contain embedded blanks.
  3. Identifiers must have a prefix which identifies the data type.
  4. Identifiers should never be all uppercase.
 42 If a procedure contains a Dim statement and strName is assigned as the identifier, strName can be used
  1. anywhere in the project.
  2. only in the procedure where the Dim statement is shown.
  3. anywhere in the project if the variable name is changed to mstName.
  4. only once in the procedure.
 43 A variable that is declared in the general declarations module of a form is a(n)
  1. module-level variable.
  2. local variable.
  3. identifying variable.
  4. general variable.
 44 Which operator(s) has(have) the highest order of precedence in arithmetic expressions?
  1. Multiplication and division
  2. Addition and subtraction
  3. exponentiation
  4. Operators are not significant, all calculations are evaluated from left to right.
 45 What will be the value of intTotal after execution of this statement? Assume that intValue = 2.
intTotal = ((intValue + 2) * (intValue + 4)) / intValue + 1
  1. 8
  2. 9
  3. 12
  4. 13
  5. None of the above.
 46 Which of the following is not a valid statement about the Val function?
  1. The Val function is used to convert the value in a text box to a numeric value.
  2. Val stands for value.
  3. The Val function returns a value of 1 if it is used on an empty text box.
  4. The Val function must be supplied with an argument.
 47 In order to control the way information should appear when it is displayed or printed out, you can use
  1. the Val function.
  2. a string variable.
  3. a constant.
  4. the formatting functions.
 48 Which of the following is not one of the VB formatting functions?
  1. FormatCurrency
  2. FormatPercent
  3. FormatDateTime
  4. FormatDollars


 49 Each ELSE will be matched with the last unmatched IF, regardless of indentation.
 50 Message boxes can be used to test if the user has input data that is a reasonable value.
 51 If intA <> intB Then evaluates True when intA=3 and intB=5.


 52 When comparing strings, which one of the following strings is less than the others, based on the ASCII code?
  2. onetwothree
  3. OneTwoThree
  4. 1Two3
 53 The text property of a text box behaves like a
  1. string.
  2. numeric.
  3. variant.
  4. literal.
 54 In order to determine if the user has input a value, and not a string, into a text box, you can use
  1. a nested If.
  2. an If statement.
  3. the IsNumeric function.
  4. an instant watch.
 55 You can use _______________ as your project executes in order to view the values of data or messages.
  1. the Calls Dialog Box
  2. the Procedure Box
  3. the Immediate window
  4. Step Into

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 the VB statement to clear a text box named txtName.

2. Write the VB statement to reset the insertion point into a text box named txtName.

3. Write the VB statement to make a label named lblAnswer become invisible.

4. Write the VB statement to assign the numeric value 4 into a variable named intNumber.

5. Write the VB statement to assign the value contained in a text box named txtWidth to a label named lblWidth.

6. Use a With statement to clear a text box named txtPlace and to reset the insertion point to that text box.

7. Write a statement that declares a variable named intQuantity of type Integer.

8. Write a statement that declares a variable named A to store monetary values.

9. Declare a string named UserName.

10. Write a statement that computes the average of variables named A, B, and C and stores the value in the variable named D.

11. Write a statement that formats a value to three positions past the decimal (thousandth's place).

12. Write a statement that sets the text box named txtPlace to the empty string.

13. Write a statement that uses the Val function to convert the string literal "123" to a value and assign it to the Integer variable, intQuantity.

14. Write an If statement that assigns the value of 10 to the variable intSum if intNum is greater than 19. Otherwise, the If statement will assign the value of 5 to intSum.

15. Write an If statement that assigns the string "hello" to the text box txtMessage if the value of intQuantity is less than 15 or greater than 44. The same If statement should also assign the string "goodbye" to txtMessage if the value of intQuantity is equal to 30.

CIS 230 Home PageExam Information