You are on page 1of 16

Test Bank for Microsoft Visual Basic 2010 for Windows, Web, Office, and Database Application

Test Bank for Microsoft Visual Basic 2010 for


Windows, Web, Office, and Database Applications
Comprehensive, 1st Edition

To download the complete and accurate content document, go to:


https://testbankbell.com/download/test-bank-for-microsoft-visual-basic-2010-for-windo
ws-web-office-and-database-applications-comprehensive-1st-edition/

Visit TestBankBell.com to get complete for all chapters


Chapter 6: Loop Structures

MULTIPLE RESPONSE

Modified Multiple Choice

1. ____ is a fundamental process that repeats instructions until a condition is true or while a condition is
true.
a. Iteration c. Looping
b. Concatenation d. Documenting
ANS: A, C PTS: 1 REF: 378

2. Instead of typing the menu name on a MenuStrip object, you can add a ____ by clicking the Type Here
box’s list arrow and selecting the appropriate choice
a. radio button c. menu item
b. combo box d. text box
ANS: B, C, D PTS: 1 REF: 383

3. A compound operator allows you to ____ values, storing the result in the same variable.
a. add c. compare
b. multiply d. divide
ANS: A, C, D PTS: 1 REF: 396

4. The ____ values used in a For...Next loop can vary based on input from a user.
a. beginning c. ending
b. step d. range
ANS: A, B, C PTS: 1 REF: 404

5. The Publish Wizard allows you to create an install file to be placed on a ____.
a. floppy disk c. Web server
b. network drive d. hard drive
ANS: B, C, D PTS: 1 REF: 426

MODIFIED TRUE/FALSE

1. When used in a menu name, the asterisk character is used to indicate that a character is a hot key.
_________________________

ANS: F, ampersand

PTS: 1 REF: 383

2. Menu item hot keys are case sensitive. _________________________

ANS: F, are not

PTS: 1 REF: 385


3. Double-clicking a menu item in design mode opens the code editing window to the Click event
handler for that menu item. _________________________

ANS: T PTS: 1 REF: 385

4. Smart actions can be specified for a menu by using Action Tags. _________________________

ANS: T PTS: 1 REF: 386

5. The Checked property of a ListBox object identifies which item in the ListBox has been selected.
_________________________

ANS: F, SelectedItem

PTS: 1 REF: 395

MULTIPLE CHOICE

1. A(n) ____ is a group of commands presented in a list.


a. action list c. menu
b. input box d. status bar
ANS: C PTS: 1 REF: 380

2. The ____ prefix is used for a MenuStrip object.


a. menu c. mst
b. mns d. mnu
ANS: D PTS: 1 REF: 382

3. The ____ character is used to indicate that a letter is a hot key on a menu item.
a. ampersand (&) c. back slash (\)
b. forward slash (/) d. underscore (_)
ANS: A PTS: 1 REF: 383

4. The hot key for a menu item can be activated with the keyboard by pressing the ____ key and the hot
key at the same time.
a. ALT c. CTRL
b. SHIFT d. TAB
ANS: A PTS: 1 REF: 383

5. A(n) ____ key is a keyboard shortcut for opening a menu.


a. hot c. legend
b. spot d. index
ANS: A PTS: 1 REF: 383
6. As shown in the accompanying figure, Visual Basic 2010 contains a(n) ____ Tag that allows you to
create a full standard menu bar commonly provided in Windows programs.
a. Menu c. Legend
b. Action d. Glossary
ANS: B PTS: 1 REF: 386

7. The feature shown in the accompanying figure provides an easy way for you to specify ____ actions
for an object as you design a form.
a. baseline c. indexed
b. smart d. object-oriented
ANS: B PTS: 1 REF: 386

8. The ____ function provides a dialog box that asks the user for input and provides an input area.
a. InputArea c. MessageBox
b. InputBox d. UserEntry
ANS: B PTS: 1 REF: 387

9. A ____ object displays a collection of items, or values, with one item per line.
a. TextBox c. ListBox
b. RadioButton d. CheckBox
ANS: C PTS: 1 REF: 390

10. Which line of code will add the value “East” to a ListBox object named lstDirections?
a. lstDirections.Add(“East”) c. lstDirections.AddValue(“East”)
b. lstDirections.Items.Add(“East”) d. lstDirections.Items.AddValue(“East”)
ANS: B PTS: 1 REF: 391

11. To remove all objects from a ListBox object, the ____ method is used.
a. Clear c. Empty
b. Items.Clear d. Items.Empty
ANS: A PTS: 1 REF: 392

12. The ____ property of a ListBox object identifies which item in the ListBox was selected.
a. Item c. Selected
b. ItemSelected d. SelectedItem
ANS: D PTS: 1 REF: 395

13. A(n) ____ variable collects a total value over a period of time.
a. catalog c. register
b. glossary d. accumulator
ANS: D PTS: 1 REF: 396

14. A(n) ____ variable keeps track of how many times a loop has executed.
a. counter c. glossary
b. accumulator d. register
ANS: A PTS: 1 REF: 396

15. A ____ operator allows you to perform arithmetic operations with a variable and store the results back
to that variable.
a. logical c. compressed
b. rational d. compound
ANS: D PTS: 1 REF: 396

16. The compound operator ____ adds the value of the right operand to the value of the left operand and
stores the result in the left operand’s variable.
a. ++ c. =+
b. += d. ==
ANS: B PTS: 1 REF: 397

17. The compound operator ____ is used to add a string to an existing string.
a. &= c. &&
b. =& d. ==
ANS: A PTS: 1 REF: 397

18. A(n) ____ is a single repetition of a loop.


a. rotation c. revolution
b. iteration d. accumulation
ANS: B PTS: 1 REF: 399

19. A ____ loop is best used when the specific number of iterations required is known.
a. Do…While c. For...Next
b. Do…Until d. For…Until
ANS: C PTS: 1 REF: 399

20. A loop’s ____ variable is a numeric variable that keeps track of the number of iterations the loop
completes.
a. compound c. matrix
b. accumulated d. control
ANS: D PTS: 1 REF: 399

21. The ____ follows the keyword For in a For...Next loop.


a. keyword Next c. keyword To
b. keyword Step d. control variable
ANS: D PTS: 1 REF: 399

22. A For...Next loop with a beginning value of 1, an ending value of 25, and a Step value of 3 will
execute ____ times.
a. 3 c. 9
b. 8 d. 25
ANS: C PTS: 1 REF: 400

23. How many times will the following loop execute?


For intCount = 10 To 16 Step 2
‘Body of Loop
Next
a. 3 c. 6
b. 4 d. 7
ANS: B PTS: 1 REF: 400

24. How many times will the following loop execute?


For intCount = 10 To 1 Step -2
‘Body of loop
Next
a. 4 c. 9
b. 5 d. 10
ANS: B PTS: 1 REF: 401

25. If ____ appears as the first line of a loop, the loop is a top-controlled Do loop that will execute as long
as a condition remains true.
a. Loop While c. Loop Until
b. Do While d. Do Until
ANS: B PTS: 1 REF: 406

26. A ____-controlled loop tests the condition before the loop body is executed.
a. bottom c. top
b. key d. function
ANS: C PTS: 1 REF: 406

27. A ____-controlled loop tests the condition after the code in the loop body has been executed.
a. bottom c. top
b. function d. key
ANS: A PTS: 1 REF: 406

28. If ____ appears as the last line of a loop, the loop is a bottom-controlled Do loop that will execute as
long as a condition remains true.
a. Loop While c. Loop Until
b. Do While d. Do Until
ANS: A PTS: 1 REF: 409

29. If ____ appears as the first line of a loop, the loop is a top-controlled Do loop that will stop execution
when a condition becomes true.
a. Loop While c. Loop Until
b. Do While d. Do Until
ANS: D PTS: 1 REF: 410

30. If ____ appears as the last line of a loop, the loop is a bottom-controlled Do loop that will stop
execution when a condition becomes true.
a. Loop While c. Until
b. Do While d. Loop Until
ANS: D PTS: 1 REF: 412

31. As demonstrated in the accompanying figure, a loop that does not terminate is called a(n) ____ loop.
a. breakaway c. runaway
b. infinite d. unstoppable
ANS: B PTS: 1 REF: 412

32. Using a preset value for the variable tested in a loop condition is a process called ____ the loop.
a. iterating c. presetting
b. priming d. rebanding
ANS: B PTS: 1 REF: 413

33. The ____ function can be used to test if data entered by the user is numeric.
a. IsInteger c. IsNumeric
b. IsNumber d. IsNonAlpha
ANS: C PTS: 1 REF: 414

34. What will be the value of the variable intTotalCount when the following code is executed?
For intOuterCount = 1 to 5
For intInnerCount = 1 to 4
intTotalCount +=1
Next
Next
a. 4 c. 9
b. 5 d. 20
ANS: D PTS: 1 REF: 416

35. When in break mode, you can use ____ to examine the value of variables.
a. DataTags c. DebugTags
b. DataTips d. DebugTips
ANS: B PTS: 1 REF: 417
36. As shown in the accompanying figure, ____ are stop points placed in the code to tell Visual Studio
2010 debugger where and when to pause the execution of the program.
a. breakpoints c. halt points
b. debug points d. tracepoints
ANS: A PTS: 1 REF: 417

37. By default, when a program reaches the item shown in the accompanying figure and pauses execution,
the line of code that is about to be executed is highlighted in what color?
a. blue c. red
b. green d. yellow
ANS: D PTS: 1 REF: 421

38. You can create a deployed version of a program by using the ____ process.
a. ClickDeploy Installation c. ClickOnce Deployment
b. ClickInstall Deployment d. ClickPublish Deployment
ANS: C PTS: 1 REF: 425

39. Before deployment, an application should be ____.


a. complete c. debugged
b. working properly d. all of the above
ANS: D PTS: 1 REF: 425

40. In order to run a program deployed with ClickOnce Deployment, the computer needs ____ installed on
it.
a. Microsoft Word c. PowerBuilder
b. Visual Studio 2010 d. none of the above
ANS: D PTS: 1 REF: 425
TRUE/FALSE

1. MenuStrip objects can be placed along any edge of the form, depending on which side is closer to the
mouse pointer.

ANS: F PTS: 1 REF: 382

2. A hot key in a menu name must be the first letter.

ANS: F PTS: 1 REF: 384

3. Writing an event handler for a menu item is the same as writing an event handler for a button click.

ANS: T PTS: 1 REF: 385

4. The InputBox function returns a null string (“”) when a user clicks the Cancel button.

ANS: T PTS: 1 REF: 387

5. The prompt message displayed in an InputBox object can be customized by the programmer.

ANS: T PTS: 1 REF: 387

6. If the user enters a numeric value in an InputBox object, the InputBox function will return a numeric
data type.

ANS: F PTS: 1 REF: 388

7. All data collected by an InputBox object is automatically converted to the best data type for the data.

ANS: F PTS: 1 REF: 388

8. An InputBox object allows user input without the need for a TextBox object on the Windows Form
object.

ANS: T PTS: 1 REF: 388

9. When the user clicks the Cancel button in an input box and the InputBox function returns a null
character, the program can test for the null character to determine further processing.

ANS: T PTS: 1 REF: 389

10. You must include a Step value in a For...Next loop, even if the Step value is 1.

ANS: F PTS: 1 REF: 400

11. The beginning and ending values for a For...Next loop must be predefined and cannot contain an
expression.

ANS: F PTS: 1 REF: 401

12. The Step value for a For...Next loop must be a positive whole integer value.

ANS: F PTS: 1 REF: 401


13. A Step value in a For...Next loop can be positive or negative.

ANS: T PTS: 1 REF: 401

14. It is best to indent the body of the loop, to identify clearly the code that is being repeated.

ANS: T PTS: 1 REF: 403

15. The beginning, ending, and step values used in a For...Next loop can vary based on input from a user.

ANS: T PTS: 1 REF: 404

16. In a Do While loop, the body of the loop is executed until the condition becomes true.

ANS: F PTS: 1 REF: 406

17. A top-controlled loop is always executed at least once.

ANS: F PTS: 1 REF: 406

18. Starting a loop with a preset value for the variable tested in the condition is called priming the loop.

ANS: T PTS: 1 REF: 413

19. When expecting a number from an input box, the IsNumeric function should be used to ensure that the
input data can be converted to a numeric variable.

ANS: T PTS: 1 REF: 414

20. Loops cannot be nested.

ANS: F PTS: 1 REF: 416

21. When nesting loops, the inner loop must be completely contained in the outer loop and must use a
different control variable.

ANS: T PTS: 1 REF: 422

22. Use a For...Next loop when the number of repetitions is unknown.

ANS: F PTS: 1 REF: 417

23. Breakpoints are stop points placed in the code where execution will be paused during the execution of
the program, and enter debug mode.

ANS: F PTS: 1 REF: 417


24. Only one breakpoint can be set in a program, as shown in the accompanying figure.

ANS: F PTS: 1 REF: 423

25. The installation files created by the ClickOnce Publishing Wizard can be used for a software release.

ANS: T PTS: 1 REF: 429

COMPLETION

1. A(n) ____________________ is a strip across the top of a window that contains one or more menu
names.

ANS: menu bar

PTS: 1 REF: 380

2. A(n) ____________________ is a group of commands, or items, presented in a list.

ANS: menu

PTS: 1 REF: 380

3. In Visual Studio 2010, a(n) ____________________ object is used to place menus at the top of a
Windows Application form.

ANS: MenuStrip

PTS: 1 REF: 381


4. The non-graphical Toolbox objects, such as MenuStrip objects, are organized and displayed below the
form in the ____________________ at the bottom of the Visual Studio interface.

ANS: Component Tray

PTS: 1 REF: 382

5. The ____________________ procedure of the Windows Form object closes the form and causes the
program to exit.

ANS: Close

PTS: 1 REF: 385

6. A(n) ____________________ object is a dialog box that prompts the user to enter a value.

ANS: InputBox

PTS: 1 REF: 387

7. The values in a ListBox are called ____________________.

ANS: items

PTS: 1 REF: 390

8. The ____________________ property of a ListBox identifies which item is selected.

ANS: SelectedItem

PTS: 1 REF: 395

9. The keyword ____________________ is the last line of a For loop.

ANS: Next

PTS: 1 REF: 399

10. A(n) ____________________ value is the value in a For...Next loop that is added to, or subtracted
from, the beginning value on each iteration of the loop.

ANS:
Step
step

PTS: 1 REF: 400

11. A(n) ____________________ loop should be used when the iterations should continue while or until a
condition is true or false.

ANS: Do

PTS: 1 REF: 405


12. A(n) ____________________ loop should be used when the iterations should continue as long as a
condition remains true.

ANS: Do While

PTS: 1 REF: 405

13. A(n) ____________________ loop should be used when the iterations should continue until a
condition becomes true.

ANS: Do Until

PTS: 1 REF: 406

14. A(n) ____________________ loop is a loop placed completely inside another loop.

ANS: nested

PTS: 1 REF: 416

15. The process of ____________________ involves resolving defects in the program code.

ANS: debugging

PTS: 1 REF: 417

16. A(n) ____________________ is used to pause the execution of code while debugging.

ANS: breakpoint

PTS: 1 REF: 417

17. While in break mode, you can examine the values in all variables that are within the scope of
execution through the use of ____________________.

ANS: DataTips

PTS: 1 REF: 417

18. After an application is completely debugged and working properly, you can ____________________
it.

ANS: deploy

PTS: 1 REF: 425

19. In Visual Basic 2010, a deployed program can be created easily by using ____________________
Deployment.

ANS: ClickOnce

PTS: 1 REF: 425

20. The ____________________ Wizard is used to publish a program using ClickOnce Deployment.
ANS: Publish

PTS: 1 REF: 426

MATCHING

Identify the letter of the choice that best matches the phrase or definition.
a. ListBox f. For...Next
b. wizard g. breakpoint
c. bottom-controlled h. looping
d. infinite i. InputBox
e. accumulator j. Do Until
1. The process of repeating a set of instructions while a condition is true or until a condition is true
2. Objects that can be assigned a default value representing the most likely user input
3. Used to publish a program using ClickOnce Deployment
4. Items added to this kind of object during design phase are available for selection by the user during
program execution
5. A variable that contains an accumulated value such as a running total
6. Loop that should be used when code is to be executed a known, exact number of times
7. Loop in which the body of the loop is executed until the condition becomes true
8. A loop that is always executed at least once
9. A loop that never ends
10. Identified in the code editor with a bullet to the left of the line number and highlighting of the code on
that line

1. ANS: H PTS: 1 REF: 378


2. ANS: I PTS: 1 REF: 388
3. ANS: B PTS: 1 REF: 426
4. ANS: A PTS: 1 REF: 393
5. ANS: E PTS: 1 REF: 396
6. ANS: F PTS: 1 REF: 399
7. ANS: J PTS: 1 REF: 406
8. ANS: C PTS: 1 REF: 406
9. ANS: D PTS: 1 REF: 412
10. ANS: G PTS: 1 REF: 419

ESSAY

1. Explain what a compound operator is, and of what it consists.

ANS:
A compound operator allows you to add, subtract, multiple, divide, use modulus or exponents, or
concatenate strings, storing the result in the same variable. An assignment statement that includes a
compound operator begins with the variable that will contain the accumulated value, such as an
accumulator or a counter, followed by the compound operator. A compound operator consists of an
arithmetic operator and an equal sign. The last element in the assignment statement is the variable or
literal containing the value to be used in the calculation

PTS: 1 REF: 396 TOP: Critical Thinking


2. How does a Do loop work? What is the difference between a Do While loop and a Do Until loop? A
top-controlled loop and a bottom-controlled loop?

ANS:
In a Do loop, the body of the loop is executed while or until a condition is true or false. The Do loop
uses a condition similar to an If…Then decision structure to determine whether it should continue
looping. In this way you can use a Do loop to execute a body of statements an indefinite number of
times.

Visual Basic 2010 provides two types of Do loops: the Do While loop and the Do Until loop. Both Do
loops execute statements repeatedly until a specified condition becomes true or false. Each loop
examines a condition to determine whether the condition is true. The Do While loop executes as long
as the condition is true.

The Do Until loop executes until the condition becomes true.

Do loops are either top-controlled or bottom-controlled, depending on whether the condition is tested
before the loop begins or after the body of the loop has executed one time. A top-controlled loop is
tested before the loop is entered; the body of a top-controlled loop might not be executed at all because
the condition being tested might be true before any processing in the loop occurs.

Bottom-controlled loops test the condition at the bottom of the loop, so the body of a
bottom-controlled loop is executed at least once..

PTS: 1 REF: 405-406 TOP: Critical Thinking

3. Discuss what a breakpoint is and how to use it.

ANS:
A good way to collect information is to pause the execution of the code where a possible error could
occur. One way to pause execution is to use breakpoints. Breakpoints are stop points placed in the
code to tell the Visual Studio 2010 debugger where and when to pause the execution of the
application. During this pause, the program is in break mode. While in break mode, you can examine
the values in all variables that are within the scope of execution through the use of DataTips.

PTS: 1 REF: 417 TOP: Critical Thinking

CASE

Critical Thinking Questions


Case 6-1

Chris is trying to decide which kind of loop is the best loop for him to use to solve a couple of
different programming challenges that he faces.

1. Chris knows the exact number of repetitions he needs the loop to execute. Which of the following is
the best choice for him?
a. top-controlled Do While c. bottom-controlled Do While
b. bottom-controlled Do Until d. For…Next

ANS:
D
Test Bank for Microsoft Visual Basic 2010 for Windows, Web, Office, and Database Application

PTS: 1 REF: 417

2. Chris wants to guarantee that the instructions within the loop are executed one time regardless of the
status of a condition. Which of the following should he use?

a. bottom-controlled Do Until c. For…Next


b. top-controlled Do Until d. top-controlled Do While

ANS:
A

PTS: 1 REF: 417

Critical Thinking Questions


Case 6-2

Robin thinks that she has a good handle on the use of compound operators but she wants to do a
couple of sample problems just to make certain. In both of the problems below, Robin assumes that
intResult = 24.

3. When Robin correctly calculates intResult -= 3, what value does she get?

a. 18 c. 72
b. 21 d. None of the above

ANS:
B

PTS: 1 REF: 397

4. When Robin correctly calculates intResult ^= 2, what value does she get?

a. 22 c. 48
b. 24 d. 576

ANS:
D

PTS: 1 REF: 397

Visit TestBankBell.com to get complete for all chapters

You might also like