Clearly Visual Basic: Programming with Microsoft Visual Basic 2010, Second Edition Diane Zak - eBook PDF instant download
Clearly Visual Basic: Programming with Microsoft Visual Basic 2010, Second Edition Diane Zak - eBook PDF instant download
https://ebookluna.com/download/clearly-visual-basic-programming-
with-microsoft-visual-basic-2010-second-edition-ebook-pdf/
Programming with Microsoft Visual Basic 2017 8th Edition Diane Zak - eBook
PDF
https://ebookluna.com/download/programming-with-microsoft-visual-
basic-2017-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-introduction-to-programming-using-
visual-basic-10th-edition/
(eBook PDF) Starting Out With Visual Basic 8th Edition by Tony Gaddis
https://ebookluna.com/product/ebook-pdf-starting-out-with-visual-basic-8th-
edition-by-tony-gaddis/
(eBook PDF) Starting Out With Visual Basic 7th Edition by Tony Gaddis
https://ebookluna.com/product/ebook-pdf-starting-out-with-visual-basic-7th-
edition-by-tony-gaddis/
Microsoft Visual Basic 2017 for Windows, Web, and Database Applications:
Comprehensive 1st Edition Corinne Hoisington - eBook PDF
https://ebookluna.com/download/microsoft-visual-basic-2017-for-windows-web-
and-database-applications-comprehensive-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-microsoft-visual-c-an-introduction-
to-object-oriented-programming-7th-edition/
https://ebookluna.com/product/ebook-pdf-starting-out-with-visual-c-5th-
edition/
Microsoft Visual C# Step by Step, 9th Edition John Sharp - eBook PDF
https://ebookluna.com/download/microsoft-visual-c-step-by-step-9th-edition-
ebook-pdf/
https://ebookluna.com/download/basic-japanese-second-edition-ebook-pdf/
This is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may be suppressed.
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience.
The publisher reserves the right to remove content from this title at any time if subsequent rights restrictions require it.
For valuable information on pricing, previous editions, changes to current editions, and alternate formats,
please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for materials in your areas of interest.
CLEARLY VISUAL BASIC®
P R O G R A M M I N G W I T H M I C R O S O F T ® V I S U A L B A S I C ® 2 01 0
This page intentionally left blank
SECOND EDITION
DIANE ZAK
Australia l Brazil l Japan l Korea l Mexico l Singapore l Spain l United Kingdom l United States
Clearly Visual Basic: ª 2012 Course Technology, Cengage Learning
Programming with Microsoft
ALL RIGHTS RESERVED. No part of this work covered by the copyright herein may be
Visual Basic 2010, Second Edition reproduced, transmitted, stored or used in any form or by any means graphic, electronic,
Diane Zak or mechanical, including but not limited to photocopying, recording, scanning, digitizing,
taping, Web distribution, information networks, or information storage and retrieval
Executive Editor: Marie Lee
systems, except as permitted under Section 107 or 108 of the 1976 United States
Acquisitions Editor: Brandi Shailer Copyright Act, without the prior written permission of the publisher.
Senior Product Manager: Alyssa Pratt
Freelance Product Manager: Tricia Coia
For product information and technology assistance, contact us at
Associate Product Manager: Cengage Learning Customer & Sales Support, 1-800-354-9706
Stephanie Lorenz
For permission to use material from this text or product,
Marketing Manager: Shanna Shelton
submit all requests online at cengage.com/permissions
Senior Content Project Manager: Jill Braiewa Further permissions questions can be emailed to
Quality Assurance: Green Pen QA permissionrequest@cengage.com
Art Director: Faith Brosnan
Cover Designer: Cabbage Design Company Library of Congress Control Number: 2011921829
Text Designer: Shawn Girsberger
ISBN 13: 978 1 111 53015 0
Print Buyer: Julio Esperas
ISBN 10: 1 111 53015 7
Proofreader: Suzanne Huizenga
Indexer: Alexandra Nickerson Course Technology
Compositor: Integra Software Services 20 Channel Center Street
Boston, MA 02210
USA
Some of the product names and company names used in this book have been used for
identification purposes only and may be trademarks or registered trademarks of their
respective manufacturers and sellers.
Course Technology, a part of Cengage Learning, reserves the right to revise this
publication and make changes from time to time in its content without notice.
Example: Microsoft® is a registered trademark of the Microsoft Corporation.
Cengage Learning is a leading provider of customized learning solutions with office
locations around the globe, including Singapore, the United Kingdom, Australia,
Mexico, Brazil, and Japan. Locate your local office at: www.cengage.com/global
Cengage Learning products are represented in Canada by Nelson Education, Ltd.
To learn more about Course Technology, visit
www.cengage.com/coursetechnology
To learn more about Cengage Learning, visit www.cengage.com
Purchase any of our products at your local college store or at our preferred online store
www.cengagebrain.com
Brief Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
C H AP T E R 1 I Am Not a Control Freak! (Control Structures) . . . . . . . . . .1
C H AP T E R 2 First You Need to Plan the Party (Problem-Solving Process) . . . 11
C H AP T E R 3 I Need a Tour Guide (Introduction to Visual Basic 2010) . . . . . 27
C H AP T E R 4 Do It Yourself Designing (Designing Interfaces) . . . . . . . . . 49
C H AP T E R 5 The Secret Code (Assignment Statements) . . . . . . . . . . . 67
C H AP T E R 6 Where Can I Store This? (Variables and Constants) . . . . . . . 81
C H AP T E R 7 What’s Wrong with It? (Syntax and Logic Errors) . . . . . . . . .101
C H AP T E R 8 Decisions, Decisions, Decisions (Selection Structure) . . . . . .115
C H AP T E R 9 Time to Leave the Nest (Nested Selection Structures) . . . . . .139
C H AP T E R 1 0 So Many Paths . . . So Little Time (Multiple-Alternative
Selection Structures) . . . . . . . . . . . . . . . . . . . .159
C H AP T E R 1 1 Testing, Testing . . . 1, 2, 3 (Selecting Test Data) . . . . . . . .183
C H AP T E R 1 2 How Long Can This Go On? (Pretest Loops) . . . . . . . . . . .203
C H AP T E R 1 3 Do It, Then Ask Permission (Posttest Loops) . . . . . . . . . .231
C H AP T E R 1 4 Let Me Count the Ways (Counter-Controlled Loops) . . . . . . .241
C H AP T E R 1 5 I’m on the Inside; You’re on the Outside (Nested Loops) . . . . .261
C H AP T E R 1 6 I Hear You Are Breaking Up (Sub Procedures) . . . . . . . . . .279
C H AP T E R 1 7 Talk to Me (Function Procedures) . . . . . . . . . . . . . . .303
C H AP T E R 1 8 A Ray of Sunshine (One-Dimensional Arrays) . . . . . . . . . .319
C H AP T E R 1 9 Parallel and Dynamic Universes (More on One-Dimensional
Arrays) . . . . . . . . . . . . . . . . . . . . . . . . . . .341
C H AP T E R 2 0 Table Tennis, Anyone? (Two-Dimensional Arrays) . . . . . . . .363
C H AP T E R 2 1 Building Your Own Structure (Structures) . . . . . . . . . . . .383
vi
CONTENTS
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Preface
Clearly Visual Basic: Programming with Microsoft Visual Basic 2010, Second Edition is designed
for a beginning programming course. The book assumes students have no previous
programming knowledge or experience. However, students should be familiar with basic
Windows skills and file management. The book’s primary focus is on teaching programming
concepts, with a secondary focus on teaching the Visual Basic programming language. In other
words, the purpose of the book is to teach students how to solve a problem that requires a
computer solution. The Visual Basic language is used as a means of verifying that the solution
works correctly.
Approach
Rather than focusing on a specific programming language, Clearly Visual Basic:
Programming with Microsoft Visual Basic 2010, Second Edition focuses on programming
concepts that are common to all programming languages—such as input, output, selection,
and repetition. Concepts are introduced, illustrated, and reinforced using simple examples
and applications, which are more appropriate for a first course in programming. The
concepts are spread over many short chapters, allowing students to master the material one
small piece at a time. Because its emphasis is on teaching the fundamentals of programming,
the book covers only the basic controls, properties, and events available in Visual Basic.
Each chapter provides the steps for creating and/or coding an application that uses the
concepts covered in the chapter. The videos and PDF files that accompany each chapter are
designed to help students master the chapter’s concepts.
Another Random Scribd Document
with Unrelated Content
169 Digesta, xlix. 16. 6. 7.
170 Ibid. xlviii. 21. 3 pr. Cf. Bourquelot, op. cit. iii. 543 sq.;
Gibbon, Decline and Fall of the Roman Empire, v. 326; Lecky,
History of European Morals, i. 219.
188 Thomas Aquinas, op. cit. ii.-ii. 64. 5. 3. Cf. St. Augustine, De
Civitate Dei, i. 25.
191 Bourquelot, op. cit. iv. 263. Morselli, op. cit. p. 196 sq.
192 Louis XIV., ‘Ordonnance criminelle,’ A.D. 1670, xxii. 1, in
Isambert, Decrusy, and Taillandier, Recueil général des anciennes
lois françaises, xviii. 414.
194 Stephen, History of the Criminal Law of England, iii. 104. For
earlier times see Bracton, De Legibus et Consuetudinibus Angliæ,
fol. 150, vol. ii. 504 sq.
198 Serpillon, Code Criminel, ii. 223. Cf. Louis XIV., ‘Ordonnance
criminelle,’ A.D. 1670, xxii. 1, in Isambert, Decrusy, and Taillandier,
op. cit. xviii. 414.
207 Bourquelot, loc. cit. iv. 263. Hyltén-Cavallius, op. cit. i. 459;
Nordström, Bidrag till den svenska samhälls-författningens
historia, ii. 331 (Swedes), von Wlislocki, ‘Tod und Totenfetische im
Volkglauben der Siebenbürger Sachsen,’ in Am Ur-Quell, iv. 53.
208 Wuttke, op. cit. § 756, p. 474; Frank, op. cit. iv. 498 sq.;
Lippert, Der Seelencult, p. 11 (people in various parts of
Germany). Schiffer, in Am Ur-Quell, iii. 50 (Polanders).
211 See infra, on Regard for the Dead. Contact with a self-
murderer’s body is considered polluting (Prexl, ‘Geburts- und
Todtengebräuche der Rumänen in Siebenbürgen,’ in Globus, lvii.
30; Hyltén-Cavallius, Wärend och Wirdarne, i. 459, 460, and ii.
412). We are told that in the eighteenth century people did not
dare to cut down a person who had hanged himself, though he
was found still alive (Frank, op. cit. iv. 499). Among the Bannavs
of Cambodia everybody who takes part in the burial of a self-
murderer is obliged to undergo a certain ceremony of purification,
whereas no such ceremony is prescribed in the case of other
burials (Mittheil. d. Geogr. Ges. zu Jena, iii. 9).
However, side by side with the extreme seventy with which suicide
is viewed by the Christian Church, we find, even in the Middle Ages,
instances of more humane feelings towards its perpetrator. In
mediæval tales and ballads true lovers die together and are buried in
the same grave; two roses spring through the turf and twine lovingly
together.212 In the later Middle Ages, says M. Bourquelot, “on voit
qu’à mesure qu’on avance, l’antagonisme devient plus prononcé
entre l’esprit religieux et les idées mondaines relativement à la mort
volontaire. Le clergé continue à suivre la route qui a été tracée par
Saint Augustin et à déclarer le suicide criminel et impie; mais la
tristesse et le désespoir n’entendent pas sa voix, ne se souviennent
pas de ses prescriptions.”213 The revival of classical learning,
accompanied as it was by admiration for antiquity and a desire to
imitate its great men, not only increased the number of suicides, but
influenced popular sentiments on the subject.214 Even the Catholic
casuists, and later on philosophers of the school of Grotius and
others, began to distinguish certain cases of legitimate suicide, such
as that committed to avoid dishonour or probable sin, or that of a
condemned person saving himself from torture by anticipating an
inevitable death, or that of a man offering himself to death for the
sake of his friend.215 Sir Thomas More, in his Utopia, permits a
person who is suffering from an incurable and painful disease to take
his own life, provided that he does so with the agreement of the
priests and magistrates; nay, he even maintains that these should
exhort such a man to put an end to a life which is only a burden to
himself and others.216 Donne, the well-known Dean of St. Paul’s,
wrote in his younger days a book in defence of suicide, “a
Declaration,” as he called it, “of that paradoxe, or thesis, that Self-
homicide is not so naturally sin, that it may never be otherwise.” He
there pointed out the fact—which ought never to be overlooked by
those who derive their arguments from “nature”—that some things
may be natural to the species, and yet not natural to every individual
member of it.217 In one of his essays Montaigne pictures classical
cases of suicide with colours of unmistakable sympathy. “La plus
volontaire mort,” he observes, “c’est la plus belle. La vie despend de
la volonté d’aultruy; la mort, de la nostre.”218 The rationalism of the
eighteenth century led to numerous attacks both upon the views of
the Church and upon the laws of the State concerning suicide.
Montesquieu advocated its legitimacy:—“La société est fondée sur un
avantage mutuel; mais lorsqu’elle me devient onéreuse, qui
m’empêche d’y renoncer? La vie m’a été donnée comme une faveur;
je puis donc la rendre lorsqu’elle ne l’est plus: la cause cesse, l’effet
doit donc cesser aussi.”219 Voltaire strongly opposed the cruel laws
which subjected a suicide’s body to outrage and deprived his
children of their heritage.220 If his act is a wrong against society,
what is to be said of the voluntary homicides committed in war,
which are permitted by the laws of all countries? Are they not much
more harmful to the human race than self-murder, which nature
prevents from ever being practised by any large number of men?221
Beccaria pointed out that the State is more wronged by the emigrant
than by the suicide, since the former takes his property with him,
whereas the latter leaves his behind.222 According to Holbach, he
who kills himself is guilty of no outrage on nature or its author; on
the contrary, he follows an indication given by nature when he parts
from his sufferings through the only door which has been left open.
Nor has his country or his family any right to complain of a member
whom it has no means of rendering happy, and from whom it
consequently has nothing more to hope.223 Others eulogised suicide
when committed for a noble end,224 or recommended it on certain
occasions. “Suppose,” says Hume, “that it is no longer in my power
to promote the interest of society; suppose that I am a burthen to it;
suppose that my life hinders some person from being much more
useful to society. In such cases my resignation of life must not only
be innocent but laudable.”225 Hume also attacks the doctrine that
suicide is a transgression of our duty to God. “If it would be no crime
in me to divert the Nile from its course, were I able to do so, how
could it be a crime to turn a few ounces of blood from their natural
channel? Were the disposal of human life so much reserved as the
peculiar province of the Almighty that it were an encroachment on
his right for men to dispose of their own lives, would it not be
equally wrong of them to lengthen out their lives beyond the period
which by the general laws of nature he had assigned to it? My death,
however voluntary, does not happen without the consent of
Providence; when I fall upon my own sword, I receive my death
equally from the hands of the Deity as if it had proceeded from a
lion, a precipice, or a fever.”226
212 See Bourquelot, loc. cit. iv. 248; Gummere, Germanic
Origins, p. 322.
215 Buonafede, op. cit. p. 148 sqq. Lecky, op. cit. ii. 55.
Thus the main arguments against suicide which had been set forth
by pagan philosophers and Christian theologians were scrutinised
and found unsatisfactory or at least insufficient to justify that severe
and wholesale censure which was passed on it by the Church and
the State. But a doctrine which has for ages been inculcated by the
leading authorities on morals is not easily overthrown; and when the
old arguments are found fault with new ones are invented. Kant
maintained that a person who disposes of his own life degrades the
humanity subsisting in his person and entrusted to him to the end
that he might uphold it.227 Fichte argued that it is our duty to
preserve our life and to will to live, not for the sake of life, but
because our life is the exclusive condition of the realisation of the
moral law through us.228 According to Hegel it is a contradiction to
speak of a person’s right over his life, since this would imply a right
of a person over himself, and no one can stand above and execute
himself.229 Paley, again, feared that if religion and morality allowed
us to kill ourselves in any case, mankind would have to live in
continual alarm for the fate of their friends and dearest relations230
—just as if there were a very strong temptation for men to shorten
their lives. But common sense is neither a metaphysician nor a
sophist. When not restrained by the yoke of a narrow theology, it is
inclined in most cases to regard the self-murderer as a proper object
of compassion rather than of condemnation, and in some instances
to admire him as a hero. The legislation on the subject therefore
changed as soon as the religious influence was weakened. The laws
against suicide were abolished in France by the Revolution,231 and
afterwards in various other continental countries;232 whilst in
England it became the custom of jurymen to presume absence of a
sound mind in the self-murderer—perjury, as Bentham said, being
the penance which prevented an outrage on humanity.233 These
measures undoubtedly indicate not only a greater regard for the
innocent relatives of the self-murderer, but also a change in the
moral ideas concerning the act itself.
227 Kant, Metaphysische Anfangungsgründe der Tugendlehre, p.
73.
228 Fichte, Das System der Sittenlehre, p. 339 sqq. See also ibid.
pp. 360, 391.
239 See supra, ii. 237 sqq.; Josephus, De bello Judaico, iii. 8. 5;
Plato, Leges, ix. 873; Aristotle, Ethica Nicomachea, v. 11. 2 sq.
7 Cf. Butler, op. cit. p. 339 sq.; Dugald Stewart, Philosophy of the
Active and Moral Powers of Man, ii. 346 sq.
Being so little noticed by custom and public opinion, and still less
by law, most self-regarding duties hardly admit of a detailed
treatment. In a general way it may be said that progress in
intellectual culture has, in some respects, been favourable to their
evolution; Darwin even maintains that, with a few exceptions, self-
regarding virtues are not esteemed by savages.8 The less developed
the intellect, the less apt it is to recognise the remoter consequences
of men’s behaviour; hence more reflection than that exercised by the
savage may be needed to see that modes of conduct which
immediately concern a person’s own welfare at the same time affect
the well-being of his neighbours or the whole community of which
he is a member. So also, owing to his want of foresight, the savage
would often fail to notice how important it may be to subject one’s
self to some temporary deprivation or discomfort in order to attain
greater happiness in the future. We have noticed above that many
savages hardly ever correct their children,9 and this means that one
of the chief sources from which the notions of self-regarding duties
spring is almost absent among them. But on the other hand it must
also be remembered that disinterested antipathies, another cause of
such notions, exercise more influence upon the unreflecting than
upon the reflecting moral consciousness, and that many magical and
religious ideas which at the lower stages of civilisation give rise to
duties of a self-regarding character are no longer held by people
more advanced in culture.
8 Darwin, Descent of Man, p. 118 sq.
50 Supra, i. 634.
75 Ibid. v. 17.
76 Ibid. v. 1; vi. 9.
77 Ibid. v. 4.
78 Ibid. v. 8.
79 Ibid. v. 8, 11.
80 Ibid. v. 8.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookluna.com