Professional Documents
Culture Documents
This document is organized chronologically, using the same heading in red that you see in the textbook. Under each
heading, you will find (in order): a Chapter Summary, Lecture Notes, Figures and Boxes found in the section, if any,
Teacher Tips, Classroom Activities, and Lab Activities. Pay special attention to teaching tips and activities geared
toward quizzing your students, which will enhance their critical thinking skills and encourage experimentation within
the software.
In addition to this Instructor’s Manual, our Instructor’s Resources also contain PowerPoint Presentations, Test Banks,
and other supplements to aid in your teaching experience.
Table of Contents
Chapter Objectives
302: Introduction
304: User Interface Design
322: Use Loops to Perform Repetitive Tasks
341: Use a DataTip with Breakpoints
346: Publish an Application with ClickOnce Deployment
350: Program Design
354: Guided Program Development
368: Code Listing
End of Chapter Material
Glossary of Key Terms
Chapter Objectives
Students will have mastered the material in Chapter Six when they can:
⚫ Add a MenuStrip object ⚫ Avoid infinite loops
⚫ Use the InputBox function ⚫ Prime a loop
⚫ Display data using the ListBox object ⚫ Validate data
⚫ Add a Background Image ⚫ Create a nested loop
⚫ Understand the use of counters and ⚫ Select the best type of loop
accumulators ⚫ Debug using DataTips at breakpoints
⚫ Understand the use of compound operators ⚫ Publish a finished application using
⚫ Repeat a process using a For...Next loop ClickOnce technology
⚫ Repeat a process using a Do loop
© 2018 Cengage. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Visual Basic 2017 Instructor’s Manual Page 2 of 11
358: Introduction
SUMMARY
A fundamental process in a program is to repeat a series of instructions either while a condition is true
(or not true) or until a condition is true (or not true). The process of repeating a set of instructions while
or until a condition is true is called looping, or iteration. The programming project for this chapter is
called the Fitness Challenge application, and it uses a loop to request and display the weight loss
amounts of the team members. The application also includes a Clear command, an Exit command, input
validation, and it displays the average weight loss to one decimal place.
LECTURE NOTES
• Define looping structure (or iteration structure)
• Point out that this is another major programming structure found in any programming language; it
allows a series of instructions to be repeated until a certain condition is met
• Define looping (or iteration)
• Introduce the programming project to be developed in this chapter using Figures 6-1 and 6-2, and
describe the part that looping will play in this application
• Define input box using Figure 6-3
• Point out that this application also implements a menu bar and data editing features
CLASSROOM ACTIVITIES
1. Quick Quiz:
1) What is another term for looping? (Answer: iteration)
2) What is an input box? (Answer: A dialog box that allows a user to enter input)
2. Critical Thinking: In addition to the example listed in the text, what are some other examples of
instances when looping could be used?
LECTURE NOTES
• Point out that the user interface for the chapter project includes three new elements: a menu, the
input box, and a list
• Define menu bar and menu using Figure 6-4
• Use Figures 6-5 through 6-9 to illustrate placing a MenuStrip object on a Windows Form
• Explain what a hot key is and explain how to create one on a menu item
• Explain that selecting menu items triggers events, and that menu items each have event handlers
• Use Figures 6-10 and 6-11 to illustrate coding an event handler for a menu item
• Define Action Tag and smart actions
© 2018 Cengage. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Visual Basic 2017 Instructor’s Manual Page 3 of 11
• Use Figures 6-12 through 6-14 to illustrate inserting a full standard menu for a MenuStrip object by
using the Action Tag
• Introduce the InputBox object for obtaining user input
• Describe the general format of the InputBox function using Figure 6-15
• Review the code sample and resulting InputBox shown in Figures 6-16 and 6-17
• Describe how to assign a default value to appear in the InputBox dialog box using Figures 6-18 and
6-19
• Review the sample program’s implementation of the InputBox dialog box and its related code
shown in Figures 6-20 and 6-21
• Introduce the ListBox object
• Use Figures 6-22 through 6-24 to illustrate adding a ListBox object to a Windows Form object
• Describe the general format for adding items to a ListBox object shown in Figure 6-25, and review
the sample code shown in Figure 6-26
• Discuss the behavior of a ListBox when the number of items exceeds the size of the viewable list
using Figure 6-27, contrasted with the list in Figure 6-24
• Explain how to remove all items from a ListBox’s list with the Clear method using Figures 6-28 and
6-29
• Use Figures 6-30 through 6-33 to illustrate adding items to a ListBox object during the form design
• Introduce the SelectedItem property of a ListBox object
• Use Figure 6-34 to describe the general format for assigning the SelectedItem property, and review
the sample code shown in Figure 6-35
• Explain the function of the BackgroundImage property of the Form object, and the companion
BackgroundImageLayout property
• Use Figures 6-36 and 6-37 to illustrate changing the background image on the form
• Define accumulator and counter
• Explain how a computer performs accumulation using the code sample shown in Figure 6-38
• Define compound operator
• Discuss each of the compound operators shown in Figure 6-39, and remind students how an
assignment statement works
• Review the sample code on page 322 and its result shown in Figure 6-40
• Describe the use of compound operators for string concatenation shown in Figure 6-41 and in the
accompanying code on page 322
FIGURES: 6-4, 6-5, 6-6, 6-7, 6-8, 6-9, 6-10, 6-11, 6-12, 6-13, 6-14, 6-15, 6-16, 6-17, 6-18, 6-19, 6-20, 6-
21, 6-22, 6-23, 6-24, 6-25, 6-26, 6-27, 6-28, 6-29, 6-30, 6-31, 6-32, 6-33, 6-34, 6-35, 6-36, 6-37, 6-38, 6-
39, 6-40, 6-41
BOXES
1. Heads Up: Review the alternatives to typing the menu name on a MenuStrip object.
4. Heads Up: Discuss the use of the InputBox object to gather data without the use of a TextBox for the
requested value on the Windows Form object.
© 2018 Cengage. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Visual Basic 2017 Instructor’s Manual Page 4 of 11
5. Consider This: Can I control where the InputBox appears on the screen? Discuss the use of the X and
Y positions to govern the location of the InputBox on the screen.
6. Critical Thinking: Can I remove a background image from the Form object? Yes. To remove the
picture in the background of a form, in the Properties window press and hold or right-click the ellipsis
button of the BackgroundImage property and select Reset.
7. Critical Thinking: Why are accumulators typically found within a loop? An accumulator calculates a
running total. For example, at a basketball game, a three-point shot adds three points to the present
score, so an accumulator of score += 3 adds three points to the existing score. The repetition of the game
allows many three pointers to be scored, so each time the scorekeeper taps or clicks the three-point
button, the loop repeats and the score code statement within the loop accumulates three more points in
its value.
8. Heads Up: Point out the advantage of the use of compound operators.
TEACHER TIPS
Students new to programming often have difficulty grasping accumulation and tend to think in terms of
collecting all the data and then adding it up. Spending extra time on this topic is very helpful for
students who are new to programming.
Compare and contrast the handling of the loop counter variable in a Do loop and in a For...Next loop: In
a Do loop, the programmer must manually control the changes to the loop counter variable with the
loop body; in a For...Next loop, the programmer should not manually make any changes to the loop
counter variable within the loop body.
Point out that by using variables for the arguments of the InputBox function, a single InputBox function
call can be made within the loop that will handle both normal input and display a user error message
asking for re-entry of data.
CLASSROOM ACTIVITIES
1. Quick Quiz:
1) Which form object will produce a menu bar on a Windows Form object? (Answer: MenuStrip)
2) Which property of a ListBox object represents the item chosen by the user? (Answer:
SelectedItem)
3) The ____ property can be used to control the appearance of a background image on the form.
(Answer: BackgroundImageLayout)
2. Critical Thinking: What is the difference between clearing out an entire list and simply clearing the
selection in a list?
3. Critical Thinking: What are the limitations about the formatting of an InputBox? How would
professional programmers get around the limitations in order to provide the additional user visual
guidance and input data validation?
© 2018 Cengage. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Visual Basic 2017 Instructor’s Manual Page 5 of 11
LAB ACTIVITIES
1. Have the students examine the menus in Visual Studio to identify key characteristics of menus, such
as separator bars, the ellipsis leading to a dialog box, the arrow leading to a submenu, checked menu
items, etc.
LECTURE NOTES
• Define iteration and remind students that the power of a computer is in its ability to perform the
same operations quickly and repetitively
• Point out that there are two main types of loops in Visual Basic: For...Next and Do loops
• Introduce the For...Next loop for use when the number of iterations is known
• Use Figure 6-42 to describe the general format of a For...Next loop, and review the sample code
shown in Figure 6-43
• Walk through the looping process and explain the use of the counter variable using Figure 6-44
• Describe the purpose of the Step value in a For...Next loop and the various ways it can be used as
shown in Figures 6-45 through 6-48
• Discuss the sample code in Figure 6-49, and use Figures 6-50 through 6-53 to illustrate using
IntelliSense to create this code
• Explain that all components in the For...Next loop syntax can be represented by variables as shown
by the example in Figures 6-54 and 6-55
• Remind students that the For...Next loop is used when the exact number of iterations is known
• Introduce the Do loop for creating a loop when the number of iterations will be based on a certain
condition change
• Briefly review decision structures
• Point out that there are two types of Do loops in Visual Basic: Do While and Do Until
• Introduce the Do While loop, and point out that it continues to execute while the condition
remains true
• Introduce the Do Until loop, and point out that it continues to execute until the condition becomes
true
• Define top-controlled loop and bottom-controlled loop, and describe how the location of the
condition being tested affects the number of iterations that will occur
• Describe the general format of a top-controlled Do While loop as shown in Figure 6-56, and review
the sample code shown in Figure 6-57
• Define infinite loop, and walk through the iteration process and the values of the loop control
variable shown in Figure 6-58
• Use Figures 6-59 through 6-61 to illustrate creating a Do While loop using IntelliSense
• Describe the general format of a bottom-controlled Do While loop as shown in Figure 6-62, and
review the sample code shown in Figure 6-63
• Walk through the iteration process and the values of the loop control variable shown in Figure 6-64
© 2018 Cengage. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Visual Basic 2017 Instructor’s Manual Page 6 of 11
• Point out that although the condition being tested was the same in both loops, the number of
iterations that actually occurred was quite different
• Review the concept of a Do Until loop, pointing out that this type of loop runs until the specified
condition becomes true
• Describe the general format of the top-controlled Do Until loop shown in Figure 6-65, and review
the sample code shown in Figure 6-66
• Describe the general format of the bottom-controlled Do Until loop shown in Figure 6-67
• Remind students that the InputBox will return a null string value if the user clicks the Cancel
button
• Describe the process of controlling user input loops using an InputBox dialog box shown in Figure
6-68
• Revisit the term infinite loop and discuss the sample code shown in Figure 6-68, which includes an
infinite loop, pointing out that an infinite loop occurs when the loop counter in a Do loop is not
correctly handled
• Define priming the loop, and review the sample code in Figure 6-69, which demonstrates priming
the loop; point out that two conditions are tested in this loop, and both must be primed
• Remind students of the need to validate all data entered by the user
• Describe the process of validating user input from the InputBox dialog box shown in Figures 6-70
and 6-71
• Review the sample code in Figure 6-72, which implements the data validation
• Point out that loops can be nested
• Review the sample code in Figure 6-73 and its results shown in Figure 6-74
• Review the considerations for choosing between Do loops and For...Next loops, between Do While
and Do Until loops, and between top-controlled and bottom-controlled loops
FIGURES: 6-42, 6-43, 6-44, 6-45, 6-46, 6-47, 6-48, 6-49, 6-50, 6-51, 6-52, 6-53, 6-54, 6-55, 6-56, 6-57, 6-
58, 6-59, 6-60, 6-61, 6-62, 6-63, 6-64, 6-65, 6-66, 6-67, 6-68, 6-69, 6-70, 6-71, 6-72, 6-73, 6-74
BOXES
1. Heads Up: Point out the advantage of the use of compound operators.
2. Heads Up: Distinguish between the uses of top-controlled loops and bottom-controlled loops.
3. Critical Thinking: In a payroll program, should I use a For loop or Do While loop to repeat the
process of entering the hours for each employee every two weeks? Typically a Do While loop is the
better option because the number of employees fluctuates. If you do not know the exact number of
iterations, it is best to use the Do While loop structure.
4. Consider This: How do I know which type of loop to use? Discuss the circumstances under which a
given type of loop is the best one to use, and discuss how much of the decision comes down to
programmer preference.
TEACHER TIPS
Pretest and posttest loops are alternative terms for top-controlled and bottom-controlled loops that
students may encounter if they use other Visual Basic resources.
© 2018 Cengage. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Another random document with
no related content on Scribd:
is past, the temperature falls very rapidly, and one sees no more of
these insects.
On February 4 we started to complete the circuit of the lake and
reach Delgi by way of the Zegi peninsula. Our road lay across flat
land, bordered by marshes and full of swamps and quagmires.
Sometimes the marshes stretch a long way into the land, and long
detours had to be made to avoid them. I saw yams for the first time
in Abyssinia growing just above the swampy tracts in this region. We
had to cross three rivers with rocky beds, which were made rougher
and more slippery by loose stones. To add to our difficulties, our
guide twice led us out of the right path, and once to a ford which was
impassable for the donkeys. In this way we lost nearly three hours.
At lunch time we sent the baggage-train on ahead of us. The latter
part of the journey was over a beaten track, and gave us no trouble.
We overtook the baggage animals and their escort just as they
entered the undulating ground which forms the approach to the
peninsula of Zegi. We pitched our camp near the shore of a little bay
of which this promontory was the further boundary.
While we were on the road I received a scribbled note from
Crawley, who told me that one of his soldiers was ill, had lain down
and refused to move. I rode back at his request, and found the
invalid under a tree. He said, “Leave me alone. I want to die.” It was
evident at a glance that he was suffering from ague. The only
remedy which we had at hand was chartreuse. I gave him a big “nip”
of the cordial, and it had an excellent effect upon him. He was able
to ride to the end of the journey, and was none the worse for the
effort. I venture to commend this incident to the consideration of
strict teetotalers.
The village near which we were encamped is that which is marked
as Furje on Stecker’s map. The district affords a curious example of
feudal tenure in Abyssinia. We had quitted Tecla Haimanot’s
dominions, and the land on which our camp stood was under the
control of a certain chief called Fituari[97] Ali, a feudatory of Ras
Mangousha. He dwelt close to the town of Zegi, but had no
jurisdiction within its boundary, though his lordship was valid in a
region extending beyond the town to the Abai.
The chieftain had gone to attend the marriage of Ras
Mangousha’s daughter, and had left his son in authority. So we sent
a messenger with an escort to carry the news of our arrival to this
young Habash with due formality. He brought back an uncivil reply to
the effect that the Fituari’s son was absent, and if we wanted
anything we had better go and find him. This was sent by his
majordomo. While we were waiting for tea to be served, Johannes
reported that the young Habash was approaching, and we saw him
at a little distance attended by a band of followers, some of whom
carried guns. Our interpreter asked what he should say to this
truculent young man, and we bade him explain that we only asked
leave to pass through the land, and should require nothing unless it
were to purchase a little grain for our animals. We always sought to
avoid trouble with the natives, and therefore impressed upon
Johannes that he should show we wished to be friendly, and say we
hoped the Fituari’s son would come and have a drink with us.
Johannes departed with his message, and presently we heard a
great hubbub—many Habashes talking at once at the top of their
high-pitched voices. We wondered what gave rise to so much
excitement. Presently Johannes emerged from the crowd and
approached us slowly. The young man’s answer was that he would
speak with us when he had seen the King’s letter. Now, this permit
and all our credentials had been dispatched on February 1 from
Bahardar Georgis to Ras Mangousha that we might obtain his leave
to travel through his territories beyond the Abai, and we did not
expect our messenger to return until late on the following day.
It was an uncomfortable situation. The Ras’s reply might be
unfavourable. In that case we should be confronted by the necessity
of retracing our steps over the whole of the toilsome journey by the
lake side. We all longed to kick the tiresome coxcomb who was in
our way, and went to dinner in a glum mood.
We were obliged to spend the following day (Feb. 5) in inaction
awaiting the return of our messenger with Ras Mangousha’s answer.
I busied myself with the camera, having every reason to believe that
no photographs of this tract of country had ever been taken.
During the morning we received a visit from the head man of Zegi.
We thought it a favourable sign that he gave us a very pleasant and
courteous welcome. This young man, Hyli by name, was about
nineteen years of age. I learned afterwards that he was studying the
ancient Geez language under the tuition of the priests of Zegi, and
presume that he intended to “go into the Church.” These candidates
for orders are not permitted to smoke or drink strong liquor while
they are in statu pupillari. A similar restriction would scarcely be
popular in our own ancient universities.
Hyli, we found, had a large consignment of coffee to send to the
market at Gallabat. It is his business to collect the dues payable on
this produce before it leaves the village, and the revenue so obtained
is handed to Ras Mangousha. Hyli had now come to request that his
caravan might join ours during the journey through the “rain-
country”—that borderland between Abyssinia and the Soudan,
which, as I have said, is infested by bandits. We had every reason to
win friends where we could, and every wish to please the young
Habash, so we consented willingly. He told us that the coffee was
already at Delgi, and that he had been informed of the date of our
arrival at that village, at Korata and at Woreb, and had been looking
forward to our coming for a month past. In the evening he sent us a
present of flour and fowls.
After this visit, I walked to the township of Zegi. It is surrounded by
a thick hedge of incense-bush, and this forms the boundary between
the Fituari’s jurisdiction and Hyli’s. Zegi very closely resembles
Korata. It consists of groups of tokhuls scattered among small,
square enclosures where the coffee bushes grow apparently
untended. These plantations, with the cottages and churches among
them, cover the whole promontory. I should estimate the population,
when I saw the place, at about three thousand souls.
Dr. Stecker’s account of his visit to the town is brief and
interesting, and I quote it. I saw nothing of the stone dwellings which
he describes, and think they must have been replaced by straw
tokhuls since 1881. He wrote:—
“On June 7 I made a tankoa-journey to the peninsula of Zegi, and
climbed to the highest peak, Tekla Haimanot (2074 metres above
sea-level, according to barometrical measurement), which afforded
extremely important survey-bearings.” The traveller then mentions
his visit to Livlivo, Adina, and the island of Dek, and adds, “The Zegi
peninsula is especially famed for its coffee plantations. Some coffee-
trees are as much as a metre in girth. The coffee is mostly exported
to Metemmeh” (Gallabat), “less goes to Massowah, but it is not
considered so good as that of Korata. Besides coffee the Ensete
banana flourishes here conspicuously, and also the edible species
(Musa Ensete edulis); but, unfortunately, in recent years these
charming plantations have been almost entirely destroyed by a
species of pig called Assama (potamochoerus penicillatus),[98] which
is found here in hundreds. This remarkable animal feeds almost
entirely on the roots of these fine bananas. What struck me here
particularly was the neatness of the tokhuls, which are chiefly of
stone, and in general all villages on Lake Tsana have a much
cleanlier and more pleasant appearance than those inland. There is
no lack of clergy on the Zegi Peninsula: there are here no fewer than
seven churches with twelve hundred priests and defterers.”[99] I am
bound to say that I saw no indication during my brief stay that the
population was deplorably priest-ridden!
I was returning to camp about four o’clock in the afternoon, and
was still at some distance from it when I met a Habash, who made
me understand by signs that our messenger had brought the Ras’s
letter, and as I hastened on I noticed that the news was already
public property. Upon reaching camp I saw our man, grimy and
travel-stained. He and a companion, with one mule to ride, had
covered about a hundred and thirty miles in four days over very
rough country, and they had waited while the Ras attended to our
business; so they had not let the grass grow under their feet. I felt
sorry for the mule. Walda Mariam had had charge of this business.
We had given him one day’s rest at Bahardar Georgis after his return
with Tecla Haimanot’s message, and then dispatched him on this
second journey. It is expected of these runners, when they are in
charge of a missive from the Negus or a great chief, that they shall
not sleep till they have delivered it. The man bowed low, and handed
the Ras’s letters to me in a manner which showed that he now made
me responsible for their custody. I then learned, by the aid of an Arab
interpreter, that the chief’s reply was of the most favourable kind, and
that he had sent mandates to all concerned to give us every
furtherance on our way round the lake. He also inquired very
courteously about our health and our progress, and had sent a
soldier from his own guard as a special escort for the party. The Ras,
moreover, had even furnished us with letters to chiefs through whose
lands we should not pass on the road to Delgi, to be used in case we
wished to turn aside from the way and visit the hinterland of the lake
district. And, best of all, there was a communication addressed to
Fituari Ali’s son, enjoining upon him that he should show us every
civility. Johannes, who had been absent from camp when the
messenger arrived, had returned by the time my companions came
back from an excursion. The despatches were then interpreted to
them in French, and we enjoyed the prospect of our enemy’s
discomfiture. It was resolved that the mandate to him should be
delivered on the following morning. I noticed that the Habashes did
not appear to make common cause with Ali’s son, but seemed
pleased at our success. Among the Ras’s letters was one to Hyli,
which we sent to him immediately, though it was scarcely required in
his case. Zody was the bearer of it.
CHAPTER XI