0% found this document useful (0 votes)
2 views

Programming With Microsoft Visual Basic 2015 7th Edition Diane Zak download

The document provides information about the 7th edition of 'Programming with Microsoft Visual Basic 2015' by Diane Zak, including details on its content and structure. It also includes links to download this and other related programming textbooks. The book covers various programming concepts and techniques using Visual Basic 2015.

Uploaded by

elizerojasvb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Programming With Microsoft Visual Basic 2015 7th Edition Diane Zak download

The document provides information about the 7th edition of 'Programming with Microsoft Visual Basic 2015' by Diane Zak, including details on its content and structure. It also includes links to download this and other related programming textbooks. The book covers various programming concepts and techniques using Visual Basic 2015.

Uploaded by

elizerojasvb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

Programming With Microsoft Visual Basic 2015 7th

Edition Diane Zak download

https://ebookbell.com/product/programming-with-microsoft-visual-
basic-2015-7th-edition-diane-zak-5312274

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Programming With Microsoft Visual Basic 2012 6th Edition Zak

https://ebookbell.com/product/programming-with-microsoft-visual-
basic-2012-6th-edition-zak-55132386

Programming With Microsoft Visual Basic 2010 Vbnet Programming 5th


Edition Zak

https://ebookbell.com/product/programming-with-microsoft-visual-
basic-2010-vbnet-programming-5th-edition-zak-55139980

Programming With Microsoft Visual Basic 2017 Mindtap Course List 8th
Edition Zak

https://ebookbell.com/product/programming-with-microsoft-visual-
basic-2017-mindtap-course-list-8th-edition-zak-55132312

Clearly Visual Basic Programming With Microsoft Visual Basic 2010 2nd
Edition Diane Zak

https://ebookbell.com/product/clearly-visual-basic-programming-with-
microsoft-visual-basic-2010-2nd-edition-diane-zak-2382420
Clearly Visual Basic Programming With Microsoft Visual Basic 2012 3rd
Edition Diane Zak

https://ebookbell.com/product/clearly-visual-basic-programming-with-
microsoft-visual-basic-2012-3rd-edition-diane-zak-4178308

Programming Microsoft Windows With Microsoft Visual Basic Net Core


Reference Prodeveloper Illustrated Edition Petzold

https://ebookbell.com/product/programming-microsoft-windows-with-
microsoft-visual-basic-net-core-reference-prodeveloper-illustrated-
edition-petzold-1273112

Programming Microsoft Sql Server 2000 With Microsoft Visual Basic Net
1st Edition Dobson

https://ebookbell.com/product/programming-microsoft-sql-
server-2000-with-microsoft-visual-basic-net-1st-edition-
dobson-55141988

Microsoft Aspnet Programming With Visual Basic Net Version 2003 Step
By Step 1st Edition G Andrew Duthie

https://ebookbell.com/product/microsoft-aspnet-programming-with-
visual-basic-net-version-2003-step-by-step-1st-edition-g-andrew-
duthie-1352776

Programming With Microsoft Visual C Net Sixth Edition George Shepherd


David Kruglinski

https://ebookbell.com/product/programming-with-microsoft-visual-c-net-
sixth-edition-george-shepherd-david-kruglinski-62157456
PROGRAMMING WITH
MICROSOFT® VISUAL BASIC® 2015

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Seventh Edition

PROGRAMMING
WITH MICROSOFT®
VISUAL BASIC® 2015

DIANE ZAK

Australia • Brazil • Mexico • Singapore • United Kingdom • United States

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
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.

Important Notice: Media content referenced within the product description or the product
text may not be available in the eBook version.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Programming with Microsoft® Visual Basic® © 2016 Cengage Learning
2015, Seventh Edition
WCN: 02-200-203
Diane Zak
Product Director: Kathleen McMahon ALL RIGHTS RESERVED. No part of this work covered by the copyright
herein may be reproduced, transmitted, stored or used in any form or by
Product Team Manager: Kristin McNary any means graphic, electronic, or mechanical, including but not limited to
Senior Product Manager: Jim Gish photocopying, recording, scanning, digitizing, taping, Web distribution,
Senior Content Developer: Alyssa Pratt information networks, or information storage and retrieval systems, except
as permitted under Section 107 or 108 of the 1976 United States Copyright
Product Assistant: Abigail Pufpaff
Act, without the prior written permission of the publisher.
Marketing Manager: Eric LaScola
Senior Production Director:
For product information and technology assistance, contact us at
Wendy Troeger Cengage Learning Customer & Sales Support, 1-800-354-9706
Production Director: Patty Stephan For permission to use material from this text or product, submit all
Senior Content Project Manager: requests online at www.cengage.com/permissions
Jennifer K. Feltri-George Further ­permissions ­questions can be emailed to
[email protected]
Managing Art Director: Jack Pendleton
Cover image(s):
Library of Congress Control Number: 2015940168
© Rudchenko Liliia/Shutterstock.com
ISBN: 978-1-285-86026-8
Unless otherwise noted all screenshots are
Cengage Learning
courtesy of Microsoft Corporation
20 Channel Center Street
Open Clip art source: OpenClipArt Boston, MA 02210
USA

Cengage Learning is a leading provider of customized learning solutions


with employees residing in nearly 40 different countries and sales in more
than 125 countries around the world. Find your local representative at
www.cengage.com

Cengage Learning products are represented in Canada by


Nelson Education, Ltd.

For your course and learning solutions, visit www.cengage.com


Purchase any of our products at your local college store or at our
preferred online store www.cengagebrain.com
Notice to the Reader
Publisher does not warrant or guarantee any of the products described herein or
perform any independent analysis in connection with any of the product informa-
tion contained herein. Publisher does not assume, and expressly disclaims, any
obligation to obtain and include information other than that provided to it by the
manufacturer. The reader is expressly warned to consider and adopt all safety
­precautions that might be indicated by the activities described herein and to avoid
all potential hazards. By following the instructions contained herein, the reader
­willingly assumes all risks in connection with such instructions. The publisher
makes no representations or warranties of any kind, including but not limited to,
the ­warranties of ­fitness for particular purpose or merchantability, nor are any such
­representations implied with respect to the material set forth herein, and the
­publisher takes no responsibility with respect to such material. The publisher shall
not be liable for any special, consequential, or exemplary damages resulting, in
whole or part, from the readers’ use of, or reliance upon, this material.

Printed in the United States of America


Print Number: 01 Print Year: 2016

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
v

Brief Contents

Pref ace . . . . . . . . . . . . . . . . . . . . . . . . . xv i i
Read T h is B ef o re You Begi n . . . . . . . . . . . . . . . . xxi i
O verview An In t ro du ct io n to Programmi ng . . . . . . . . . . . . . . . 1
Chapter 1 An In t ro du ct io n to V i sual Basi c 2 0 1 5 . . . . . . . . . . . . . 9
Chapter 2 Des ig n in g Applicati ons . . . . . . . . . . . . . . . . . . 59
Chapter 3 U s in g Var iables and Constants . . . . . . . . . . . . . . . 111
Chapter 4 T h e Select io n Structure . . . . . . . . . . . . . . . . . . 179
Chapter 5 M o re o n t h e Selecti on Structure . . . . . . . . . . . . . . 247
Chapter 6 T h e Repet it io n Structure . . . . . . . . . . . . . . . . . 315
Chapter 7 Su b an d F u n ct ion Procedures . . . . . . . . . . . . . . . 389
Chapter 8 St r in g M an ipu lati on . . . . . . . . . . . . . . . . . . . . 449
Chapter 9 Ar r ays . . . . . . . . . . . . . . . . . . . . . . . . . 499
Chapter 10 St r u ct u res an d Sequenti al Access Fi l es . . . . . . . . . . . 559
Chapter 11 Clas s es an d Obj ects . . . . . . . . . . . . . . . . . . . 609
Chapter 12 Web Applicat io ns . . . . . . . . . . . . . . . . . . . . . 671
Chapter 13 Wo r k in g w it h Access Databases and LI NQ . . . . . . . . . . 723
Chapter 14 Acces s Dat abases and SQL . . . . . . . . . . . . . . . . 777
A ppendix A F in din g an d F ixing Program Errors . . . . . . . . . . . . . 821
A ppendix B GU I Des ig n Gu idel i nes . . . . . . . . . . . . . . . . . . 839
A ppendix C V is u al B as ic Co nv ersi on Functi ons . . . . . . . . . . . . . 845
A ppendix D V is u al B as ic 201 5 Cheat Sheet . . . . . . . . . . . . . . 847
A ppendix E Cas e Pro ject s . . . . . . . . . . . . . . . . . . . . . . 865
A ppendix F M u lt iple F o r m s and Di al og Box es . . . . . . . . . . . . O nl i ne
Index . . . . . . . . . . . . . . . . . . . . . . . . . . 869

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vi

Contents

P ref ace . . . . . . . . . . . . . . . . . . . . . . . . . xvi i


R ead T h is B ef o re Yo u Begi n . . . . . . . . . . . . . . . . xxi i

OVERVIEW A n In t ro du ct io n t o Pro grammi ng . . . . . . . . . . . . . . . 1


Programming a Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
The Programmer’s Job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Employment Opportunities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Visual Basic 2015 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
A Visual Basic 2015 Demonstration . . . . . . . . . . . . . . . . . . . . . . . 4
Using the Chapters Effectively . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

C HAPTER 1 A n In t ro du ct io n t o V is ual Basi c 2 0 1 5 . . . . . . . . . . . . . 9


L ESS ON A The Splash Screen Application . . . . . . . . . . . . . . . . . . . . . 11
Managing the Windows in the IDE . . . . . . . . . . . . . . . . . . . . . . . 14
The Windows Form Designer Window . . . . . . . . . . . . . . . . . . . . . . 15
The Solution Explorer Window . . . . . . . . . . . . . . . . . . . . . . . . . 16
The Properties Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Properties of a Windows Form . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Name Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
The Text Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
The StartPosition Property . . . . . . . . . . . . . . . . . . . . . . . . . . 20
The Font Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The Size Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Setting and Restoring a Property’s Value . . . . . . . . . . . . . . . . . . . . . 21
Saving a Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Closing the Current Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Opening an Existing Solution . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Exiting Visual Studio 2015 . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

LESSON B The Toolbox W indow . . . . . . . . . . . . . . . . . . . . . . . . . . 28


The Label Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Setting the Text Property . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Setting the Location Property . . . . . . . . . . . . . . . . . . . . . . . . . 31

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vii
 

Changing a Property for Multiple Controls . . . . . . . . . . . . . . . . . . . . 31


Using the Format Menu’s Order Option . . . . . . . . . . . . . . . . . . . . . 32
The PictureBox Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Using the Format Menu to Align and Size . . . . . . . . . . . . . . . . . . . . 35
The Button Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Starting and Ending an Application . . . . . . . . . . . . . . . . . . . . . . . . 36
The Code Editor Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
The Me.Close() Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

LESSON C Using the Timer Tool . . . . . . . . . . . . . . . . . . . . . . . . . . 48


Setting the FormBorderStyle Property . . . . . . . . . . . . . . . . . . . . . . 50
The MinimizeBox, MaximizeBox, and ControlBox Properties . . . . . . . . . . . . 50
Printing the Application’s Code and Interface . . . . . . . . . . . . . . . . . . . 51
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

CHAPTER 2 Des ig n in g Applicati ons . . . . . . . . . . . . . . . . . . 59


L ESS ON A Creating an Object-Oriented Application . . . . . . . . . . . . . . . . . 62
Planning an Object-Oriented Application . . . . . . . . . . . . . . . . . . . . . 62
Identifying the Application’s Tasks . . . . . . . . . . . . . . . . . . . . . . . 63
Identifying the Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Identifying the Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Drawing a Sketch of the User Interface . . . . . . . . . . . . . . . . . . . . . 66
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

L ESSON B Building the User Inter face . . . . . . . . . . . . . . . . . . . . . . . 72


Including Graphics in the User Interface . . . . . . . . . . . . . . . . . . . . 73
Selecting Fonts for the Interface . . . . . . . . . . . . . . . . . . . . . . . . 73
Adding Color to the Interface . . . . . . . . . . . . . . . . . . . . . . . . . 74
The BorderStyle, AutoSize, and TextAlign Properties . . . . . . . . . . . . . . . 75
Adding a Text Box to the Form . . . . . . . . . . . . . . . . . . . . . . . . . 76
Locking the Controls on a Form . . . . . . . . . . . . . . . . . . . . . . . . . 77
Assigning Access Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Controlling the Tab Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii
Contents 

L ESS ON C Coding the Application . . . . . . . . . . . . . . . . . . . . . . . . . 86


Using Pseudocode to Plan a Procedure . . . . . . . . . . . . . . . . . . . . . 87
Using a Flowchart to Plan a Procedure . . . . . . . . . . . . . . . . . . . . . 88
Coding the btnClear_Click Procedure . . . . . . . . . . . . . . . . . . . . . . . 89
Assigning a Value to a Property During Run Time . . . . . . . . . . . . . . . . 90
Using the Focus Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Internally Documenting the Program Code . . . . . . . . . . . . . . . . . . . 92
Coding the btnPrint_Click Procedure . . . . . . . . . . . . . . . . . . . . . . . 93
Showing and Hiding a Control . . . . . . . . . . . . . . . . . . . . . . . . . 94
Writing Arithmetic Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 95
Coding the btnCalc_Click Procedure . . . . . . . . . . . . . . . . . . . . . . . 97
The Val Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
The Format Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Testing and Debugging the Application . . . . . . . . . . . . . . . . . . . . . .101
Assembling the Documentation . . . . . . . . . . . . . . . . . . . . . . . . . 103
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .107
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

CHAPTER 3 U s in g Var iables an d Constants . . . . . . . . . . . . . . . 111


L ESS ON A Using Variables to Store Information . . . . . . . . . . . . . . . . . . 114
Selecting a Data Type for a Variable . . . . . . . . . . . . . . . . . . . . . .114
Selecting a Name for a Variable . . . . . . . . . . . . . . . . . . . . . . . .116
Declaring a Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Assigning Data to an Existing Variable . . . . . . . . . . . . . . . . . . . . . .118
The TryParse Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
The Convert Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
The Scope and Lifetime of a Variable . . . . . . . . . . . . . . . . . . . . . . .123
Variables with Procedure Scope . . . . . . . . . . . . . . . . . . . . . . . .123
Variables with Class Scope . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Static Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Named Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Option Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
Option Explicit and Option Infer . . . . . . . . . . . . . . . . . . . . . . . . 133
Option Strict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .138
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140

LESSON B Modifying the Meyer’s Purp le Bakery Application . . . . . . . . . . . . 144


Modifying the Calculate Button’s Code . . . . . . . . . . . . . . . . . . . . . .145
Using the ToString Method to Format Numbers . . . . . . . . . . . . . . . . . .152
Concatenating Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
The InputBox Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
The ControlChars.NewLine Constant . . . . . . . . . . . . . . . . . . . . . . .158
Designating a Default Button . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
ix
 

Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162


Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .163
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

LESSON C Modifying the Load and Click Event Procedures . . . . . . . . . . . . . 167


Coding the TextChanged Event Procedure . . . . . . . . . . . . . . . . . . . . 170
Associating a Procedure with Different Objects and Events . . . . . . . . . . . . .170
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .175
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

CHAPTER 4 T h e Select io n Structure . . . . . . . . . . . . . . . . . . 179


L ESS ON A Making Decisions in a Program . . . . . . . . . . . . . . . . . . . . 182
Flowcharting a Selection Structure . . . . . . . . . . . . . . . . . . . . . . . .185
Coding Selection Structures in Visual Basic . . . . . . . . . . . . . . . . . . . .187
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
Using Comparison Operators: Swapping Numeric Values . . . . . . . . . . . . .191
Using Comparison Operators: Displaying Net Income or Loss . . . . . . . . . . .194
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Using the Truth Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Comparing Strings Containing One or More Letters . . . . . . . . . . . . . . . .203
Converting a String to Uppercase or Lowercase . . . . . . . . . . . . . . . . . .205
Using the ToUpper and ToLower Methods: Displaying a Message . . . . . . . . . 206
Summary of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213

LESSON B Creating the Treeline Resor t Application . . . . . . . . . . . . . . . . 216


Adding a Group Box to the Form . . . . . . . . . . . . . . . . . . . . . . . .216
Coding the Treeline Resort Application . . . . . . . . . . . . . . . . . . . . . .218
Coding the btnCalc Control’s Click Event Procedure . . . . . . . . . . . . . . .219
The MessageBox.Show Method . . . . . . . . . . . . . . . . . . . . . . . . . 222
Completing the btnCalc_Click Procedure . . . . . . . . . . . . . . . . . . . . .226
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .230
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .230
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

L ESSON C Coding the KeyPress Event Procedures . . . . . . . . . . . . . . . . 233


Coding the Enter Event Procedures . . . . . . . . . . . . . . . . . . . . . . . 235
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .240
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x
Contents 

C HAPTER 5 M ore o n t h e Select io n Structure . . . . . . . . . . . . . . 247


L ESS ON A Nested Selection Structures . . . . . . . . . . . . . . . . . . . . . 250
Flowcharting a Nested Selection Structure . . . . . . . . . . . . . . . . . . . .252
Coding a Nested Selection Structure . . . . . . . . . . . . . . . . . . . . . . .255
Logic Errors in Selection Structures . . . . . . . . . . . . . . . . . . . . . . .257
First Logic Error: Using a Compound Condition Rather than a Nested
Selection Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260
Second Logic Error: Reversing the Outer and Nested Decisions . . . . . . . . . .261
Third Logic Error: Using an Unnecessary Nested Selection Structure . . . . . . . 262
Fourth Logic Error: Including an Unnecessary Comparison in a Condition . . . . . 263
Multiple-Alternative Selection Structures . . . . . . . . . . . . . . . . . . . . .264
The Select Case Statement . . . . . . . . . . . . . . . . . . . . . . . . . . .267
Specifying a Range of Values in a Case Clause . . . . . . . . . . . . . . . . . 269
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .272
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275

LESSON B Modifying the Treeline Resor t Application . . . . . . . . . . . . . . . . 280


Adding a Radio Button to the Interface . . . . . . . . . . . . . . . . . . . . .282
Adding a Check Box to the Interface . . . . . . . . . . . . . . . . . . . . . .283
Modifying the Calculate Button’s Code . . . . . . . . . . . . . . . . . . . . . .285
Comparing Boolean Values . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Modifying the ClearLabels Procedure . . . . . . . . . . . . . . . . . . . . . . .291
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .294
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .295
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .295
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

LESSON C Using the TryParse Method for Data Validation . . . . . . . . . . . . . 300


Generating Random Integers . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Completing the Roll ‘Em Game Application . . . . . . . . . . . . . . . . . . . . 306
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .309
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

CHAPTER 6 T h e Repet it io n St r u ct u re . . . . . . . . . . . . . . . . . 315


L ESS ON A Repeating Program Instructions . . . . . . . . . . . . . . . . . . . . 317
The Projected Sales Application . . . . . . . . . . . . . . . . . . . . . . . . .320
The Do...Loop Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . .323
Coding the Modified Projected Sales Application . . . . . . . . . . . . . . . . .325
Counters and Accumulators . . . . . . . . . . . . . . . . . . . . . . . . . . .328
The Addition Application . . . . . . . . . . . . . . . . . . . . . . . . . . . .330
Arithmetic Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . 333
The For...Next Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . .335
A Different Version of the Projected Sales Application . . . . . . . . . . . . . .337
Comparing the For...Next and Do...Loop Statements . . . . . . . . . . . . . . .340
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .340

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xi
 

Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341


Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .342
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345

LESSON B Creating the Monthly Payment Application . . . . . . . . . . . . . . . 350


Including a List Box in an Interface . . . . . . . . . . . . . . . . . . . . . . . .351
Adding Items to a List Box . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Clearing the Items from a List Box . . . . . . . . . . . . . . . . . . . . . . .353
The Sorted Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Coding the Monthly Payment Application . . . . . . . . . . . . . . . . . . . . .355
The SelectedItem and SelectedIndex Properties . . . . . . . . . . . . . . . . .356
The SelectedValueChanged and SelectedIndexChanged Events . . . . . . . . . .358
Coding the Calculate Button’s Click Event Procedure . . . . . . . . . . . . . . .358
The Financial.Pmt Method . . . . . . . . . . . . . . . . . . . . . . . . . . . .359
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .363
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .364
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .364
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

LESSON C The Electric Bill Application . . . . . . . . . . . . . . . . . . . . . 371


Nested Repetition Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 376
The Refresh and Sleep Methods . . . . . . . . . . . . . . . . . . . . . . . . .378
Trixie at the Diner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
The Savings Account Application . . . . . . . . . . . . . . . . . . . . . . . .380
A Caution About Real Numbers . . . . . . . . . . . . . . . . . . . . . . . . .382
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

CHAPTER 7 Su b an d F u n ct ion Procedures . . . . . . . . . . . . . . . 389


L ESS ON A Sub Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
Passing Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
Passing Variables by Value . . . . . . . . . . . . . . . . . . . . . . . . . . 394
Passing Variables by Reference . . . . . . . . . . . . . . . . . . . . . . . . 397
Function Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .412
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .413
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416

L ESSON B Including a Combo Box in an Inter face . . . . . . . . . . . . . . . . . 420


Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .424
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .425
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426

L ESSON C Creating the Cerruti Company Application . . . . . . . . . . . . . . . 428


Coding the FormClosing Event Procedure . . . . . . . . . . . . . . . . . . . . .429

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xii
Contents 

Coding the btnCalc_Click Procedure . . . . . . . . . . . . . . . . . . . . . . .431


Creating the GetFwt Function . . . . . . . . . . . . . . . . . . . . . . . . . 433
Completing the btnCalc_Click Procedure . . . . . . . . . . . . . . . . . . . . .437
Rounding Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .437
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .444
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .445
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .445
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445

C HAPTER 8 S t r in g M an ipu lat io n . . . . . . . . . . . . . . . . . . . 449


L ESS ON A Working with Strings . . . . . . . . . . . . . . . . . . . . . . . . . 452
Determining the Number of Characters in a String . . . . . . . . . . . . . . . . .452
Removing Characters from a String . . . . . . . . . . . . . . . . . . . . . . . 453
The Product ID Application . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Inserting Characters in a String . . . . . . . . . . . . . . . . . . . . . . . . .455
Aligning the Characters in a String . . . . . . . . . . . . . . . . . . . . . . .456
The Net Pay Application . . . . . . . . . . . . . . . . . . . . . . . . . . . .457
Searching a String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .458
The City and State Application . . . . . . . . . . . . . . . . . . . . . . . . .460
Accessing the Characters in a String . . . . . . . . . . . . . . . . . . . . . . .461
The Rearrange Name Application . . . . . . . . . . . . . . . . . . . . . . . .462
Using Pattern Matching to Compare Strings . . . . . . . . . . . . . . . . . . . .464
Modifying the Product ID Application . . . . . . . . . . . . . . . . . . . . . . .466
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .468
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .469
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .472

LESSON B Adding a Menu to a Form . . . . . . . . . . . . . . . . . . . . . . . 475


Assigning Shortcut Keys to Menu Items . . . . . . . . . . . . . . . . . . . . .478
Coding the Exit Menu Item . . . . . . . . . . . . . . . . . . . . . . . . . . .480
Coding the txtLetter Control’s KeyPress Event . . . . . . . . . . . . . . . . . .480
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .481
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .481
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .481
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482

LESSON C Completing the Pizza Game Application . . . . . . . . . . . . . . . . 483


Coding the File Menu’s New Game Option . . . . . . . . . . . . . . . . . . . . .484
Completing the Check Button’s Click Event Procedure . . . . . . . . . . . . . .487
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .493
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .494
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .494
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

CHAPTER 9 A rr ays . . . . . . . . . . . . . . . . . . . . . . . . . 499


L ESS ON A Ar rays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
One-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . .502
Declaring a One-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . .502

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiii
 

Storing Data in a One-Dimensional Array . . . . . . . . . . . . . . . . . . . . 504


Determining the Number of Elements in a One-Dimensional Array . . . . . . . . .505
Determining the Highest Subscript in a One-Dimensional Array . . . . . . . . . . 505
Traversing a One-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . 506
The For Each...Next Statement . . . . . . . . . . . . . . . . . . . . . . . . . 507
Calculating the Average Stock Price . . . . . . . . . . . . . . . . . . . . . . .508
Finding the Highest Value . . . . . . . . . . . . . . . . . . . . . . . . . . . .511
Sorting a One-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . . . .515
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .517
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .518
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .521

LESS ON B Arrays and Collections . . . . . . . . . . . . . . . . . . . . . . . . 525


Accumulator and Counter Arrays . . . . . . . . . . . . . . . . . . . . . . . . .528
Parallel One-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . .532
The Die Tracker Application . . . . . . . . . . . . . . . . . . . . . . . . . . .536
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .540
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .540
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .541
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541

LESS ON C Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . 544


Traversing a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . 547
Totaling the Values Stored in a Two-Dimensional Array . . . . . . . . . . . . . . .548
Searching a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . . 550
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .553
Lesson C Key Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .554
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .554
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555

CHAPTER 10 St r u ct u res an d Sequenti al Access Fi l es . . . . . . . . . . . 559


L ESS ON A Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
Declaring and Using a Structure Variable . . . . . . . . . . . . . . . . . . . . .563
Passing a Structure Variable to a Procedure . . . . . . . . . . . . . . . . . . . 564
Creating an Array of Structure Variables . . . . . . . . . . . . . . . . . . . . .568
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .573
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .573
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .574

LESSON B Sequential Access Files . . . . . . . . . . . . . . . . . . . . . . . 578


Writing Data to a Sequential Access File . . . . . . . . . . . . . . . . . . . . .578
Closing an Output Sequential Access File . . . . . . . . . . . . . . . . . . . . .581
Reading Data from a Sequential Access File . . . . . . . . . . . . . . . . . . . 582
Closing an Input Sequential Access File . . . . . . . . . . . . . . . . . . . . . 586
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .589
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .589
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .590
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiv
Contents 

L ESS ON C Coding the eBook Collection Application . . . . . . . . . . . . . . . . 594


Coding the frmMain_Load Procedure . . . . . . . . . . . . . . . . . . . . . . .595
Coding the btnAdd_Click Procedure . . . . . . . . . . . . . . . . . . . . . . . 597
Aligning Columns of Information . . . . . . . . . . . . . . . . . . . . . . . . .598
Coding the btnRemove_Click Procedure . . . . . . . . . . . . . . . . . . . . . 600
Coding the frmMain_FormClosing Procedure . . . . . . . . . . . . . . . . . . . 601
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .605
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .605
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .606
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606

CHAPTER 11 C las s es an d Object s . . . . . . . . . . . . . . . . . . . 609


L ESS ON A Object-Oriented Programming Terminology . . . . . . . . . . . . . . . 612
Creating a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .613
Example 1—A Class That Contains Public Variables Only . . . . . . . . . . . . . .614
Example 2—A Class That Contains Private Variables, Public Properties, and Methods . 618
Private Variables and Property Procedures . . . . . . . . . . . . . . . . . . . 620
Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .623
Methods Other than Constructors . . . . . . . . . . . . . . . . . . . . . . . 625
Coding the Sunnyside Decks Application . . . . . . . . . . . . . . . . . . . . 626
Example 3—A Class That Contains a Parameterized Constructor . . . . . . . . . .629
Example 4—Reusing a Class . . . . . . . . . . . . . . . . . . . . . . . . . . 633
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .636
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .638
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .639

LESSON B Example 5—A Class That Contains a ReadOnly Property . . . . . . . . . . . . . 644


Example 6—A Class That Contains Auto-Implemented Properties . . . . . . . . . .649
Example 7—A Class That Contains Overloaded Methods . . . . . . . . . . . . . .651
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .657
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .658
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .658
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658

LESSON C Example 8—Using a Base Class and a Derived Class . . . . . . . . . . . 662


Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .668
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .668
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .668
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669

CHAPTER 12 We b Applicat io n s . . . . . . . . . . . . . . . . . . . . 671


L ESS ON A Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 673
Adding the Default.aspx Web Page to the Application . . . . . . . . . . . . . . . 677
Including a Title on a Web Page . . . . . . . . . . . . . . . . . . . . . . . . 679
Adding Static Text to a Web Page . . . . . . . . . . . . . . . . . . . . . . . 679
Adding Another Web Page to the Application . . . . . . . . . . . . . . . . . . . 681
Adding a Hyperlink Control to a Web Page . . . . . . . . . . . . . . . . . . . . 681

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xv
 

Starting a Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 683


Adding an Image to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . .685
Closing and Opening an Existing Web Application . . . . . . . . . . . . . . . . .687
Repositioning a Control on a Web Page . . . . . . . . . . . . . . . . . . . . . .688
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .689
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .691
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .692

LESSON B Dynamic Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . 695


Coding the Submit Button’s Click Event Procedure . . . . . . . . . . . . . . . . .699
Validating User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .701
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .704
Lesson B Key Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .705
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .705
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705

LESS ON C Creating the Satellite Radio Application . . . . . . . . . . . . . . . . 709


Using the RadioButtonList Tool . . . . . . . . . . . . . . . . . . . . . . . . .710
Using the CheckBox Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
Coding the Calculate Button’s Click Event Procedure . . . . . . . . . . . . . . . 712
Clearing the Previous Subscription Costs . . . . . . . . . . . . . . . . . . . . .715
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .717
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .718
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .718
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719

CHAPTER 13 Wo r k in g w it h Access Databases and LI NQ . . . . . . . . . . 723


L ESS ON A Database Terminology . . . . . . . . . . . . . . . . . . . . . . . . 726
Connecting an Application to a Microsoft Access Database . . . . . . . . . . . . .728
Previewing the Contents of a Dataset . . . . . . . . . . . . . . . . . . . . . .731
Binding the Objects in a Dataset . . . . . . . . . . . . . . . . . . . . . . . . .732
Having the Computer Create a Bound Control . . . . . . . . . . . . . . . . . .733
The DataGridView Control . . . . . . . . . . . . . . . . . . . . . . . . . . .736
Visual Basic Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Handling Errors in the Code . . . . . . . . . . . . . . . . . . . . . . . . . .740
The Copy to Output Directory Property . . . . . . . . . . . . . . . . . . . . . .743
Binding to an Existing Control . . . . . . . . . . . . . . . . . . . . . . . . . .744
Coding the Next Record and Previous Record Buttons . . . . . . . . . . . . . . .747
Formatting the Data Displayed in a Bound Label Control . . . . . . . . . . . . . .748
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .749
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .751
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .752

LESSON B Creating a Query . . . . . . . . . . . . . . . . . . . . . . . . . . 754


Customizing a BindingNavigator Control . . . . . . . . . . . . . . . . . . . . . 758
Using the LINQ Aggregate Operators . . . . . . . . . . . . . . . . . . . . . . .760
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .763
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .763

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvi
Contents 

Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .764


Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765

LESSON C Completing the Games Galore Application . . . . . . . . . . . . . . . 767


Coding the Games Galore Application . . . . . . . . . . . . . . . . . . . . . . 769
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .771
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .771
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .771
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773

CHAPTER 14 A c ces s Dat abas es an d SQL . . . . . . . . . . . . . . . . 777


L ESS ON A Adding Records to a Dataset . . . . . . . . . . . . . . . . . . . . . 780
Sorting the Records in a Dataset . . . . . . . . . . . . . . . . . . . . . . . . 785
Deleting Records from a Dataset . . . . . . . . . . . . . . . . . . . . . . . . 786
Lesson A Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .790
Lesson A Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791
Lesson A Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .791
Lesson A Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .792

LESSON B Structured Query Language . . . . . . . . . . . . . . . . . . . . . . 794


The SELECT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . .794
Creating a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .796
Lesson B Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .801
Lesson B Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .801
Lesson B Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .802
Lesson B Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803

LESSON C Parameter Queries . . . . . . . . . . . . . . . . . . . . . . . . . 805


Saving a Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .807
Invoking a Query from Code . . . . . . . . . . . . . . . . . . . . . . . . . . .809
The INSERT and DELETE Statements . . . . . . . . . . . . . . . . . . . . . . .811
Lesson C Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .818
Lesson C Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .819
Lesson C Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .819
Lesson C Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 820

Appendix A F in din g an d F ixin g Pro gram Errors . . . . . . . . . . . . . 821

A ppendix B GUI Des ig n Gu idelin es . . . . . . . . . . . . . . . . . . 839

APPENDIX C V is u al B as ic Co n ver s ion Functi ons . . . . . . . . . . . . . 845

APPENDIX D V i s u al B as ic 2012 Ch eat Sheet . . . . . . . . . . . . . . 847

APPENDIX E C as e Pro ject s . . . . . . . . . . . . . . . . . . . . . . 865

APPENDIX F M ult iple F o r m s an d Dial og Box es . . . . . . . . . . . . On l i ne

I n dex . . . . . . . . . . . . . . . . . . . . . . . . . . 869

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvii

Preface

Programming with Microsoft Visual Basic 2015, Seventh Edition uses Visual Basic 2015, an
object-oriented language, to teach programming concepts. This book is designed for a beginning
programming course. However, it assumes students are familiar with basic Windows skills and
file management.

Organization and Coverage


Programming with Microsoft Visual Basic 2015, Seventh Edition contains an Overview and 14
chapters that present hands-on instruction; it also contains five appendices (A through E).
An additional appendix (Appendix F) covering multiple-form applications and the FontDialog,
ColorDialog, and TabControl tools is available online at CengageBrain.com.
In the chapters, students with no previous programming experience learn how to plan and create
their own interactive Windows applications. GUI design skills, OOP concepts, and planning
tools (such as TOE charts, pseudocode, and flowcharts) are emphasized throughout the book.
The chapters show students how to work with objects and write Visual Basic statements such as
If...Then...Else, Select Case, Do...Loop, For...Next, and For Each...Next. Students also learn how
to create and manipulate variables, constants, strings, sequential access files, structures, classes,
and arrays. Chapter 12 shows students how to create both static and dynamic Web applications.
In Chapter 13, students learn how to connect an application to a Microsoft Access database,
and then use Language-Integrated Query (LINQ) to query the database. Chapter 14 continues
the coverage of databases, introducing the student to more advanced concepts and Structured
Query Language (SQL).
Appendix A, which can be covered after Chapter 3, teaches students how to locate and correct
errors in their code. The appendix shows students how to step through their code and also how
to create breakpoints. Appendix B recaps the GUI design guidelines mentioned in the chapters,
and Appendix C lists the Visual Basic conversion functions. The Visual Basic 2015 Cheat Sheet
contained in Appendix D summarizes important concepts covered in the chapters, such as the
syntax of statements, methods, and so on. The Cheat Sheet provides a convenient place for
students to locate the information they need as they are creating and coding their applications.
Appendix E contains Case Projects that can be assigned after completing specific chapters in
the book.

Approach
Programming with Microsoft Visual Basic 2015, Seventh Edition teaches programming concepts
using a task-driven rather than a command-driven approach. By working through the chapters,
which are each motivated by a realistic case, students learn how to develop applications they
are likely to encounter in the workplace. This is much more effective than memorizing a list of
commands out of context. The book motivates students by demonstrating why they need to
learn the concepts and skills covered in each chapter.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xviii
P r e fa c e Organization and Coverage

Features
Programming with Microsoft Visual Basic 2015, Seventh Edition is an exceptional textbook
because it also includes the following features:
READ THIS BEFORE YOU BEGIN This section is consistent with Cengage Learning’s
unequaled commitment to helping instructors introduce technology into the classroom.
Technical considerations and assumptions about hardware, software, and default settings are
listed in one place to help instructors save time and eliminate unnecessary aggravation.
YOU DO IT! BOXES These boxes provide simple applications that allow students to
demonstrate their understanding of a concept before moving on to the next concept. The YOU
DO IT! boxes are located almost exclusively in Lesson A of each chapter.
VISUAL STUDIO 2015 METHODS The book focuses on Visual Studio 2015 methods rather
than on Visual Basic functions. Exceptions to this are the Val and Format functions, which are
introduced in Chapter 2. These functions are covered in the book simply because it is likely that
students will encounter them in existing Visual Basic programs. However, in Chapter 3, the
student is taught to use the TryParse method and the Convert class methods rather than the
Val function. Also in Chapter 3, the Format function is replaced with the ToString method.
OPTION STATEMENTS All programs include the Option Explicit, Option Strict, and Option
Infer statements.
START HERE ARROWS These arrows indicate the beginning of a tutorial steps section in
the book.
DATABASES, LINQ, AND SQL The book includes two chapters (Chapters 13 and 14) on
databases. LINQ is covered in Chapter 13. SQL is covered in Chapter 14.
FIGURES Figures that introduce new statements, functions, or methods contain both the
syntax and examples of using the syntax. Including the syntax in the figures makes the examples
more meaningful, and vice versa.
CHAPTER CASES Each chapter begins with a programming-related problem that students
could reasonably expect to encounter in business, followed by a demonstration of an application
that could be used to solve the problem. Showing the students the completed application before
they learn how to create it is motivational and instructionally sound. By allowing the students to
see the type of application they will be able to create after completing the chapter, the students
will be more motivated to learn because they can see how the programming concepts they are
about to learn can be used and, therefore, why the concepts are important.
LESSONS Each chapter is divided into three lessons—A, B, and C. Lesson A introduces
the programming concepts that will be used in the completed application. The concepts are
illustrated with code examples and sample applications. The user interface for each sample
application is provided to the student. Also provided are tutorial-style steps that guide the
student on coding, running, and testing the application. Each sample application allows the
student to observe how the current concept can be used before the next concept is introduced.
In Lessons B and/or C, the student creates the application required to solve the problem
specified in the Chapter Case.
APPENDICES Appendix A, which can be covered after Chapter 3, teaches students how to locate
and correct errors (syntax, logic, and run time) in their code. The appendix shows
students how to step through their code and also how to create breakpoints. Appendix B
summarizes the GUI design guidelines taught in the chapters, making it easier for the student to
follow the guidelines when designing an application’s interface. Appendix C lists the Visual Basic

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xix
Organization and Coverage 

conversion functions. Appendix D contains a Cheat Sheet that summarizes important concepts
covered in the chapters, such as the syntax of statements, methods, and so on. The Cheat Sheet
provides a convenient place for students to locate the information they need as they are creating and
coding their applications. Appendix E contains Case Projects that can be assigned after completing
specific chapters in the book. Appendix F, which is available online at CengageBrain.com, covers
multiple-form applications and the FontDialog, ColorDialog, and TabControl tools.
GUI DESIGN TIP BOXES The GUI DESIGN TIP boxes contain guidelines and
recommendations for designing applications that follow Windows standards. Appendix B
provides a summary of the GUI design guidelines covered in the chapters.
TIP These notes provide additional information about the current concept. Examples
include alternative ways of writing statements or performing tasks, as well as warnings
about common mistakes made when using a particular command and reminders of related
concepts learned in previous chapters.
SUMMARY Each lesson contains a Summary section that recaps the concepts covered in
the lesson.
KEY TERMS Following the Summary section in each lesson is a listing of the key terms
introduced throughout the lesson, along with their definitions.
REVIEW QUESTIONS Each lesson contains Review Questions designed to test a student’s
understanding of the lesson’s concepts.
EXERCISES The Review Questions in each lesson are followed by Exercises, which provide
students with additional practice of the skills and concepts they learned in the lesson. The
Exercises are designated as INTRODUCTORY, INTERMEDIATE, ADVANCED, DISCOVERY,
and SWAT THE BUGS. The DISCOVERY Exercises encourage students to challenge and
independently develop their own programming skills while exploring the capabilities of Visual
Basic 2015. The SWAT THE BUGS Exercises provide an opportunity for students to detect and
correct errors in an application’s code.

New to This Edition!


U PDATED VIDEOS These notes direct students to videos that accompany each
chapter in the book. The videos explain and/or demonstrate one or more of the
chapter’s concepts. The videos have been revised from the previous edition and are
available via the optional MindTap for this text.
NEW CHAPTER CASES, EXAMPLES, APPLICATIONS, REVIEW QUESTIONS, AND
EXERCISES The chapters contain new Chapter Cases, code examples, sample applications,
Review Questions, and Exercises.
Chapters 2, 5, 6, and 12 The Visible property is now introduced in Chapter 2 rather than
in Chapter 5. Coverage of the priming and update reads was moved from Chapter 6’s Lesson A
to Chapter 6’s Lesson B. The topics covered in Chapter 6’s Lesson B are now covered in its
Lesson C and vice versa. The Financial.Pmt function is covered in Chapter 6’s Lesson B. Chapter 12,
which covers Web applications, has been revamped.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xx
P r e fa c e MindTap

Steps and Figures


The tutorial-style steps in the book assume you are using Microsoft Visual Studio Ultimate 2015
and a system running Microsoft Windows 8. The figures in the book reflect how your screen will
look if you are using a Microsoft Windows 8 system. Your screen may appear slightly different in
some instances if you are using a different version of Microsoft Windows.

Instructor Resources
The following teaching tools are available for download at our Instructor Companion Site.
Simply search for this text at sso.cengage.com. An instructor login is required.
INSTRUCTOR’S MANUAL The Instructor’s Manual that accompanies this textbook includes
additional instructional material to assist in class preparation, including items such as Sample
Syllabi, Chapter Outlines, Technical Notes, Lecture Notes, Quick Quizzes, Teaching Tips,
Discussion Topics, and Additional Case Projects.
TEST BANK Cengage Learning Testing Powered by Cognero is a flexible, online system that
allows you to:
•• author, edit, and manage test bank content from multiple Cengage Learning solutions
•• create multiple test versions in an instant
•• deliver tests from your LMS, your classroom or wherever you want

POWERPOINT PRESENTATIONS This book offers Microsoft PowerPoint slides for each
chapter. These are included as a teaching aid for classroom presentation, to make available
to students on the network for chapter review, or to be printed for classroom distribution.
Instructors can add their own slides for additional topics they introduce to the class.
SOLUTION FILES Solutions to the Lesson applications and the end-of-lesson Review
Questions and Exercises are provided.
DATA FILES Data Files are necessary for completing the computer activities in this book.
Data Files can also be downloaded by students at CengageBrain.com.

MindTap
MindTap is a personalized teaching experience with relevant assignments that guide students to
analyze, apply, and improve thinking, allowing you to measure skills and outcomes with ease.
•• Personalized Teaching: Becomes yours with a Learning Path that is built with key student
objectives. Control what students see and when they see it. Use it as-is or match to your
syllabus exactly–hide, rearrange, add and create your own content.
•• Guide Students: A unique learning path of relevant readings, multimedia and activities
that move students up the learning taxonomy from basic knowledge and comprehension to
analysis and application.
•• Promote Better Outcomes: Empower instructors and motivate students with analytics
and reports that provide a snapshot of class progress, time in course, engagement and
completion rates.

The MindTap for Programming with Microsoft Visual Basic 2015 includes videos, study tools,
and interactive quizzing, all integrated into a full eReader that contains the full content from
the printed text.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxi
Acknowledgments 

Acknowledgments
Writing a book is a team effort rather than an individual one. I would like to take this
opportunity to thank my team, especially Alyssa Pratt (Senior Content Developer), Heidi Aguiar
(Full Service Project Manager), Serge Palladino and John Freitas (Quality Assurance), Jennifer
Feltri-George (Senior Content Project Manager), and the compositors at GEX Publishing
Services. Thank you for your support, enthusiasm, patience, and hard work. Last, but certainly
not least, I want to thank the following reviewers for their invaluable ideas and comments: Cliff
Brozo, Monroe College; Anthony Cameron, Fayetteville Technical Community College, and
Tatyana Feofilaktova, ASA College. And a special thank you to Sally Douglas (College of Central
Florida) for suggesting the YOU DO IT! boxes several editions ago.
Diane Zak

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxii

Read This Before


You Begin

Technical Information
Data Files
You will need data files to complete the computer activities in this book. Your instructor may
provide the data files to you. You may obtain the files electronically at CengageBrain.com and
then navigating to the page for this book.
Each chapter in this book has its own set of data files, which are stored in a separate folder
within the VB2015 folder. The files for Chapter 1 are stored in the VB2015\Chap01 folder.
Similarly, the files for Chapter 2 are stored in the VB2015\Chap02 folder. Throughout this book,
you will be instructed to open files from or save files to these folders.
You can use a computer in your school lab or your own computer to complete the steps and
Exercises in this book.

Using Your Own Computer


To use your own computer to complete the computer activities in this book, you will need the
following:
•• A Pentium® 4 processor, 1.6 GHz or higher, personal computer running Microsoft Windows.
This book was written using Microsoft Windows 8, and Quality Assurance tested using
Microsoft Windows 10.
•• Either Microsoft Visual Studio Ultimate 2015 or Visual Studio Community Edition
installed on your computer. This book was written and Quality Assurance tested using
Microsoft Visual Studio Ultimate 2015. At the time of this writing, you can download a
free copy of the Community Edition at https://www.visualstudio.com/en-us/downloads/
visual-studio-2015-downloads-vs.

To control the display of filename extensions in Windows 8:


1. Press and hold down the Windows logo key on your keyboard as you tap the letter x.
Click Control Panel, click Appearance and Personalization, click Folder Options, and
then click the View tab.
2. Deselect the Hide extensions for known file types check box to show the extensions; or,
select the check box to hide them. Click the OK button, and then close the Appearance
and Personalization window.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxiii
Technical Information 

To always display the underlined letters (called access keys)


in Windows 8:
1. Press and hold down the Windows logo key on your keyboard as you tap the letter x.
Click Control Panel, and then click Appearance and Personalization.
2. In the Ease of Access Center section, click Turn on easy access keys, and then select
the Underline keyboard shortcuts and access keys check box. Click the OK button, and
then close the Ease of Access Center window.

To start and configure Visual Studio to match the figures and tutorial
steps in this book:
1. Use the steps on Page 11 to start Visual Studio.
2. Use the steps on Pages 12 and 13 to configure Visual Studio.

To install Microsoft Visual Basic PowerPacks 12.0:


1. Locate the vb_vbpowerpacks.exe file, which is contained in the VB2015\PowerPacks
folder. Right-click the filename and then click Run as administrator. Click the Yes button.
2. Select the “I agree to the License Terms and Privacy Policy.” check box. Either select
or deselect the check box that asks if you want to join the Visual Studio Experience
Improvement program. Click Install.
3. When the “Setup Successful!” message appears, click the Close button.
4. Start Visual Studio. Open the Toolbox window (if necessary) by clicking View on the
menu bar and then clicking Toolbox. Right-click the Toolbox window and then click
Add Tab. Type Visual Basic PowerPacks and press Enter.
5. Right-click the Visual Basic PowerPacks tab, and then click Choose Items. If necessary,
click the .NET Framework Components tab in the Choose Toolbox Items dialog box.
6. In the Filter box, type PowerPacks. You may see one or more entries for the PrintForm
control. Select Version 12’s PrintForm control, as shown in Figure 1. (Although this
book uses only the PrintForm control, you can also select Version 12’s DataRepeater,
LineShape, OvalShape, and RectangleShape controls.)

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxiv
Read This Technical Information

7. Click the OK button to close the Choose Toolbox Items dialog box. If the message “The
following controls were successfully added to the toolbox but are not enabled in the
active designer:” appears, click the OK button. The PrintForm control (as well as any
other PowerPacks controls you selected) will not appear in the Toolbox window until
you either create a new Visual Basic application or open an existing one. You will learn
how to perform both of those tasks in Chapter 1.

Figures
The figures in this book reflect how your screen will look if you are using Microsoft Visual
Studio Ultimate 2015 and a Microsoft Windows 8 system. Your screen may appear slightly
different in some instances if you are using another version of either Microsoft Visual Studio or
Microsoft Windows.

Visit Our Web Site


Additional materials designed for this textbook might be available at CengageBrain.com. Search
this site for more details.

To the Instructor
To complete the computer activities in this book, your students must use a set of data files.
These files can be obtained on the Instructor Companion Site or at CengageBrain.com.
The material in this book was written using Microsoft Visual Studio Ultimate 2015 on a
Microsoft Windows 8 system. It was Quality Assurance tested using Microsoft Visual Studio
Ultimate 2015 on a Microsoft Windows 10 system.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
OVERVIEW

An Introduction to
Programming

After studying the Overview, you should be able to:

Define the terminology used in programming


Explain the tasks performed by a programmer
Understand the employment opportunities for programmers
and software engineers
Run a Visual Basic 2015 application
Understand how to use the chapters effectively

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2
OVERVIEW An Introduction to Programming

Programming a Computer
In essence, the word programming means giving a mechanism the directions to accomplish a
task. If you are like most people, you have already programmed several mechanisms, such as
your digital video recorder (DVR), cell phone, or coffee maker. Like these devices, a computer
also is a mechanism that can be programmed.
The directions (typically called instructions) given to a computer are called computer ­programs
or, more simply, programs. The people who write programs are called programmers.
Programmers use a variety of special languages, called programming languages, to
communicate with the computer. Some popular programming languages are Visual Basic, C#,
C++, and Java. In this book, you will use the Visual Basic programming language.

The Programmer’s Job


When a company has a problem that requires a computer solution, typically it is a programmer
who comes to the rescue. The programmer might be an employee of the company; or he or she
might be a freelance programmer, which is a programmer who works on temporary contracts
rather than for a long-term employer.
First the programmer meets with the user, who is the person (or people) responsible for
describing the problem. In many cases, this person will also eventually use the solution.
Depending on the complexity of the problem, multiple programmers may be involved, and
they may need to meet with the user several times. Programming teams often contain subject
matter experts, who may or may not be programmers. For example, an accountant might be
part of a team working on a program that requires accounting expertise. The purpose of the
initial meetings with the user is to determine the exact problem and to agree on a solution.
After the programmer and user agree on the solution, the programmer begins converting
the solution into a computer program. During the conversion phase, the programmer meets
periodically with the user to determine whether the program fulfills the user’s needs and to
Overview-Programmers refine any details of the solution. When the user is satisfied that the program does what he
or she wants it to do, the programmer rigorously tests the program with sample data before
releasing it to the user, who will test it further to verify that it correctly solves the problem. In
many cases, the programmer also provides the user with a manual that explains how to use the
program. As this process indicates, the creation of a good computer solution to a problem—in
other words, the creation of a good program—requires a great deal of interaction between the
programmer and the user.

Employment Opportunities
When searching for a job in computer programming, you will encounter ads for “computer
programmers” as well as for “computer software engineers.” Although job titles and
descriptions vary, computer software engineers typically are responsible for designing an
Overview-Programmer appropriate solution to a user’s problem, while computer programmers are responsible
Qualities for translating the solution into a language that the computer can understand—a process
called coding. Software engineering is a higher-level position that requires the ability to
envision solutions. Using a construction analogy, software engineers are the architects, while
programmers are the carpenters.
Keep in mind that depending on the employer as well as the size and complexity of the user’s
problem, the design and coding tasks may be performed by the same employee, no matter what
his or her job title is. In other words, it is not unusual for a software engineer to code his or her
solution or for a programmer to have designed the solution he or she is coding.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3
Visual Basic 2015 

Programmers and software engineers need to have strong problem-solving and analytical skills,
as well as the ability to communicate effectively with team members, end users, and other
nontechnical personnel. Typically, computer software engineers are expected to have at least
a bachelor’s degree in software engineering, computer science, or mathematics, along with
practical work experience, especially in the industry in which they are employed. Computer
programmers usually need at least an associate’s degree in computer science, mathematics, or
information systems, as well as proficiency in one or more programming languages.
Computer programmers and software engineers are employed by companies in almost every
industry, such as telecommunications companies, software publishers, financial institutions,
insurance carriers, educational institutions, and government agencies. The U.S. Bureau of
Labor Statistics predicts that employment of computer software engineers will increase by
22% from 2012 to 2022. The employment of computer programmers, on the other hand,
will increase by 8% over the same period. In addition, consulting opportunities for freelance
programmers and software engineers are expected to increase as companies look for ways to
reduce their payroll expenses.
There is a great deal of competition for programming and software engineering jobs, so
jobseekers need to keep up to date with the latest programming languages and technologies.
A competitive edge may be gained by obtaining vendor-specific or language-specific
certifications, as well as knowledge of a prospective employer’s business. More information
about computer programmers and computer software engineers can be found on the U.S.
Bureau of Labor Statistics Web site at www.bls.gov.

Visual Basic 2015


In this book, you will learn how to create programs, called applications, using the Visual Basic
2015 programming language. Visual Basic 2015 is one of the languages built into Microsoft’s
newest integrated development environment: Visual Studio 2015. An integrated development
environment (IDE) is an environment that contains all of the tools and features you need to
create, run, and test your programs.
Visual Basic 2015 is an object-oriented programming language, which is a language that
allows the programmer to use objects to accomplish a program’s goal. An object is anything that
can be seen, touched, or used. In other words, an object is nearly any thing. The objects in an
object-oriented program can take on many different forms. Programs written for the Windows
environment typically use objects such as check boxes, list boxes, and buttons. A payroll
program, on the other hand, might utilize objects found in the real world, such as a time card
object, an employee object, and a check object.
Every object in an object-oriented program is created from a class, which is a pattern that the
computer uses to create the object. The class contains the instructions that tell the computer
how the object should look and behave. An object created from a class is called an instance of
the class and is said to be instantiated from the class. An analogy involving a cookie cutter and
cookies is often used to describe a class and its objects: The class is the cookie cutter, and the
objects instantiated from the class are the cookies. You will learn more about classes and objects
throughout this book.
You can use Visual Basic to create applications for the Windows environment or for the Web.
A Windows application has a Windows user interface and runs on a personal computer. A user
interface is what the user sees and interacts with while an application is running. Examples
of Windows applications include graphics programs, data-entry systems, and games. A Web
application, on the other hand, has a Web user interface and runs on a server. You access a Web

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
4
OVERVIEW An Introduction to Programming

application using your computer’s browser. Examples of Web applications include e-commerce
applications available on the Internet and employee handbook applications accessible on a
company’s intranet. You can also use Visual Basic to create applications for tablet PCs and
mobile devices, such as cell phones.

A Visual Basic 2015 Demonstration


In the following set of steps, you will run a Visual Basic 2015 application that shows you some
of the objects you will learn about in the chapters. For now, it is not important for you to
understand how these objects were created or why the objects perform the way they do. Those
questions will be answered in the chapters.
START H ERE To run the Visual Basic 2015 application:
You can also 1. Use Windows to locate and then open the VB2015\Overview folder on your computer’s
double-click the hard disk or on the device designated by your instructor. Right-click Monthly Payment
filename to run Calculator (Monthly Payment Calculator.exe) in the list of filenames and then click
the application. the Open button. (Depending on how Windows is set up on your computer, you may
or may not see the .exe extension on the filename. Refer to the Overview’s Summary
section to learn how to show/hide filename extensions.)
2. After a few moments, the Monthly Payment Calculator application shown in Figure 1
appears on the screen. The interface contains a text box, a list box, buttons, radio
buttons, and labels. You can use the application to calculate the monthly payment for
a car loan.

Don’t be
­concerned if
some of the
letters on
your screen
are not underlined.
text box
You can show/hide the
­underlined letters by
pressing the Alt key. list box
radio buttons

labels

buttons

Figure 1   Monthly Payment Calculator application

3. Use the application to calculate the monthly payment for a $22,000 loan at 3.75%
interest for five years. Type 22000 in the Principal text box. Scroll down the Interest
list box and then click 3.75 %. The radio button corresponding to the five-year term is
already selected, so you just need to click the Calculate button to compute the monthly
payment. The application indicates that your monthly payment would be $402.69.
See Figure 2.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
5
Using the Chapters Effectively 

Figure 2   Computed monthly payment

4. Now determine what your monthly payment would be if you borrowed $5,000 at 4.5%
interest for four years. Type 5000 in the Principal text box, click 4.50 % in the Interest
list box, click the 4 years radio button, and then click the Calculate button. The
Monthly payment box shows $114.02.
5. Click the Exit button to close the application.

Using the Chapters Effectively


This book is designed for a beginning programming course. However, it assumes students are
familiar with basic Windows skills and file management. The chapters in this book will help you
learn how to write programs using Microsoft Visual Basic 2015. The chapters are designed to be
used at your computer. Begin by reading the text that explains the concepts. When you come to
the numbered steps, follow the steps on your computer. Read each step carefully and completely
before you try it. As you work, compare your screen with the figures to verify your results. The
figures in this book reflect how your screen will look if you are using Visual Studio Ultimate 2015
and a Microsoft Windows 8 system. Your screen may vary in some instances if you are using
a different edition of Visual Studio or if you are using another version of Microsoft Windows.
Don’t worry if your screen display differs slightly from the figures. The important parts of the
screen display are labeled in each figure. Just be sure you have these parts on your screen.
Do not worry about making mistakes; that’s part of the learning process. Tip notes identify Tip notes are
common problems and explain how to get back on track. They also provide additional information designated by
about a procedure—for example, an alternative method of performing the procedure. the icon.

Each chapter is divided into three lessons. You might want to take a break between lessons.
Following each lesson is a Summary section that lists the important elements of the lesson.
After the Summary section is a list of the key terms (including definitions) covered in the lesson.
Following the Key Terms section are questions and exercises designed to review and reinforce
the lesson’s concepts. You should complete all of the end-of-lesson questions and several
exercises before continuing to the next lesson. It takes a great deal of practice to acquire the
skills needed to create good programs, and future chapters assume that you have mastered the
information found in the previous chapters.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
6
OVERVIEW An Introduction to Programming

Some of the end-of-lesson exercises are Discovery exercises, which allow you to both “discover”
the solutions to problems on your own and experiment with material that is not covered in
the chapter. Some lessons also contain one or more Debugging exercises. In programming, the
term debugging refers to the process of finding and fixing any errors, called bugs, in a program.
Debugging exercises provide opportunities for you to find and correct the errors in existing
applications. Appendix A, which can be covered after completing Chapter 3, guides you through
the process of locating and correcting a program’s errors (bugs).
Throughout the book, you will find GUI (graphical user interface) design tips. These tips
contain guidelines and recommendations for designing applications. You should follow these
guidelines and recommendations so that your applications conform to the Windows standards.

Summary
•• Programs are the step-by-step instructions that tell a computer how to perform a task.
•• Programmers use various programming languages to communicate with the computer.
•• The creation of a good program requires a great deal of interaction between the programmer
and the user.
•• Programmers rigorously test a program with sample data before releasing the program to
the user.
•• It’s not unusual for the same person to perform the duties of both a software engineer and a
programmer.
•• An object-oriented programming language, such as Visual Basic 2015, enables programmers
to use objects to accomplish a program’s goal. An object is anything that can be seen,
touched, or used.
•• Every object in an object-oriented program is instantiated (created) from a class, which is a
pattern that tells the computer how the object should look and behave. An object is referred
to as an instance of the class.
•• The process of locating and correcting the errors (bugs) in a program is called debugging.

The Windows •• To control the display of filename extensions, press and hold down the Windows logo
logo key looks key on your keyboard as you tap the letter x. Click Control Panel, click Appearance and
like this . Personalization, click Folder Options, and then click the View tab. Deselect the Hide
extensions for known file types check box to show the extensions; or, select the check box
to hide them.

Key Terms
Applications—programs created for the Windows environment, the Web, or mobile devices
Class—a pattern that the computer uses to create (instantiate) an object
Coding—the process of translating a solution into a language that the computer can understand
Computer programs—the directions given to computers; also called programs
Debugging—the process of locating and correcting the errors (bugs) in a program
IDE—integrated development environment

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
7
Key Terms

Instance—an object created (instantiated) from a class


Instantiated—the process of creating an object from a class
Integrated development environment—an environment that contains all of the tools
and features you need to create, run, and test your programs; also called an IDE
Object—anything that can be seen, touched, or used
Object-oriented programming language—a programming language that allows the
programmer to use objects to accomplish a program’s goal
Programmers—the people who write computer programs
Programming—the process of giving a mechanism the directions to accomplish a task
Programming languages—languages used to communicate with a computer
Programs—the directions given to computers; also called computer programs
User interface—what the user sees and interacts with while an application is running

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CHAPTER 1
An Introduction to
Visual Basic 2015

Creating a Splash Screen

In this chapter, you will use Visual Basic 2015, Microsoft’s newest version of the
Visual Basic language, to create a splash screen for the Crighton Zoo. A splash
screen is the first image that appears when an application is started. It is used to
introduce the application and to hold the user’s attention while the application is
being read into the computer’s internal memory.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
10
CHAPTER 1 An Introduction to Visual Basic 2015

Previewing the Splash Screen


Before you start the first lesson in this chapter, you will preview the completed splash screen
contained in the VB2015\Chap01 folder.
START H ERE To preview the completed splash screen:

You can also 1. Use Windows to locate and then open the VB2015\Chap01 folder on your computer’s
double-click the hard disk or on the device designated by your instructor. Right-click Zoo Splash (Zoo
filename to run Splash.exe) in the list of filenames and then click the Open button. (Depending on
the application. how Windows is set up on your computer, you may or may not see the .exe extension
on the filename. Refer to the Overview’s Summary section to learn how to show/hide
filename extensions.) After a few moments, the splash screen shown in Figure 1-1
appears on the screen. The splash screen closes when six seconds have elapsed.

Figure 1-1   Splash screen for the Crighton Zoo


Photos courtesy of the Nashville Zoo and Diane Zak

Chapter 1 is designed to help you get comfortable with the Visual Studio 2015 integrated
development environment (IDE). As you learned in the Overview, an IDE is an environment that
contains all of the tools and features you need to create, run, and test your programs. Like all the
chapters in this book, Chapter 1 contains three lessons. You should complete a lesson in full and
do all of the end-of-lesson questions and several exercises before continuing to the next lesson.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
11
The Splash Screen Application L E S S O N A

❚ L ES S ON A
After studying Lesson A, you should be able to:
•• Start and customize Visual Studio 2015
•• Create a Visual Basic 2015 Windows application
•• Manage the windows in the IDE
•• Set the properties of an object
•• Restore a property to its default setting
•• Save a solution
•• Close and open an existing solution

The Splash Screen Application


In this chapter, you will create a splash screen using Visual Basic 2015. The following set of steps
will guide you in starting Visual Studio Ultimate 2015 from Windows 8. Your steps may differ
slightly if you are using another edition of Visual Studio 2015.
To start Visual Studio Ultimate 2015: STA R T HER E

1. If necessary, tap the Windows logo key to switch to the Windows 8 tile-based mode, The Windows
and then click the Visual Studio 2015 tile. logo key looks
like this .­
2. If the Choose Default Environment Settings dialog box appears, click Visual Basic
Development Settings and then click Start Visual Studio.
If the Choose Default Environment Settings dialog box does not appear, click Tools on
the menu bar, click Import and Export Settings, select the Reset all settings radio
button, click the Next button, select the No, just reset settings, overwriting my
current settings radio button, click the Next button, click Visual Basic, and then click
the Finish button. Click the Close button to close the Import and Export Settings
Wizard dialog box.
3. Click Window on the menu bar, click Reset Window Layout, and then click the Yes
button. When you start Visual Studio Ultimate 2015, your screen will appear similar to
Figure 1-2. However, your menu bar may not contain underlined letters, called access
keys. You will learn about access keys in Chapter 2. (You can show/hide the access keys
by pressing the Alt key on your keyboard.)

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
12
CHAPTER 1 An Introduction to Visual Basic 2015

Solution Explorer
Start Page window window

Toolbox
window’s tab

Team Explorer
window’s tab

Figure 1-2   Microsoft Visual Studio Ultimate 2015 startup screen

Next, you will configure Visual Studio so that your screen and tutorial steps agree with the
figures and tutorial steps in this book. As mentioned in the Overview, the figures reflect how
your screen will look if you are using Visual Studio Ultimate 2015 and a Microsoft Windows 8
system. Your screen may vary in some instances if you are using a different edition of Visual
Studio or if you are using another version of Microsoft Windows. Don’t worry if your screen
display differs slightly from the figures.
START H ERE To configure Visual Studio:
1. Click Tools on the menu bar and then click Options to open the Options dialog box.
Click the Projects and Solutions node. Use the information shown in Figure 1-3 to
select and deselect the appropriate check boxes.

The color of
your dialog
boxes depends
on your
­computer’s
desktop theme.

select and
deselect the
appropriate
check boxes

Projects and
Solutions node

Figure 1-3   Options dialog box

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
13
The Splash Screen Application L E S S O N A

2. Expand the Text Editor node and then expand the All Languages node. Click
CodeLens and then deselect the Enable CodeLens check box.
3. Click the Debugging node and then deselect the Step over properties and operators
(Managed only) check box. Also deselect the Show elapsed time PerfTip while
debugging check box, which appears at the bottom of the list.
4. Click the OK button to close the Options dialog box.
Note: If you change your default environment settings after performing the previous
four steps, you will need to perform the steps again.
The splash screen will be a Windows application, which means it will have a Windows user
interface and run on a desktop (or laptop) computer. Recall that a user interface is what the user
sees and interacts with while an application is running. Windows applications in Visual Basic are
composed of solutions, projects, and files. A solution is a container that stores the projects and
files for an entire application. Although the solutions in this book contain only one project,
a solution can contain several projects. A project is also a container, but it stores only the files
associated with that particular project.
To create a Visual Basic 2015 Windows application: STA R T HER E

1. Click File on the menu bar and then click New Project to open the New Project dialog
box. If necessary, click the Visual Basic node in the Installed Templates list, and then
click Windows Forms Application in the middle column of the dialog box.
2. Change the name entered in the Name box to Splash Project.
3. Click the Browse button to open the Project Location dialog box. Locate and then
click the VB2015\Chap01 folder. Click the Select Folder button to close the Project
Location dialog box.
4. If necessary, select the Create directory for solution check box in the New Project
dialog box. Change the name entered in the Solution name box to Splash Solution.
Figure 1-4 shows the completed New Project dialog box in Visual Studio Ultimate 2015.
(Your dialog box may look slightly different if you are using another edition of Visual
Studio. Do not be concerned if your dialog box shows a different version of the .NET
Framework.)

your drive letter might


be different

Figure 1-4   Completed New Project dialog box in Visual Studio Ultimate 2015

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
14
CHAPTER 1 An Introduction to Visual Basic 2015

To size the 5. Click the OK button to close the New Project dialog box. The computer creates a
­Solution solution and adds a Visual Basic project to the solution. The names of the solution and
Explorer and project, along with other information pertaining to the project, appear in the Solution
Properties Explorer window. See Figure 1-5. In addition to the windows shown earlier in Figure 1-2,
­windows, three other windows appear in the IDE: Windows Form Designer, Properties, and Data
­position your mouse
Sources. (Don’t be concerned if different properties appear in your Properties window.)
pointer on the left
border of one of the
windows until the
mouse pointer becomes
a ­sizing pointer (a
horizontal line with an
arrowhead at each
end), and then drag the
border to either the left Data Sources
window’s tab solution and Auto Hide
or the right. button
project names
and information

Properties
window

Windows Form
Designer window

Figure 1-5   Solution and Visual Basic project

Managing the Windows in the IDE


In most cases, you will find it easier to work in the IDE if you either close or auto-hide the
windows you are not currently using. The easiest way to close an open window is to click the
Close button on its title bar. In most cases, the View menu provides an appropriate option
for opening a closed window. In addition to closing a window, you can also auto-hide it. You
auto-hide a window using the Auto Hide button (refer to Figure 1-5) on the window’s title
bar. The Auto Hide button is a toggle button: Clicking it once activates it, and clicking it again
deactivates it. The Toolbox and Data Sources windows in Figure 1-5 are auto-hidden windows.
START H ERE To close, open, auto-hide, and display windows in the IDE:
1. Click the Close button on the Properties window’s title bar to close the window. Then
click View on the menu bar and click Properties Window to open the window.
2. If your IDE contains the Team Explorer window, click the Team Explorer tab and then
click the Close button on the window’s title bar.
3. Click the Auto Hide (vertical pushpin) button on the Solution Explorer window. The
Solution Explorer window is minimized and appears as a tab on the edge of the IDE.
4. To temporarily display the Solution Explorer window, click the Solution Explorer tab.
Notice that the Auto Hide button is now a horizontal pushpin rather than a vertical
pushpin. To return the Solution Explorer window to its auto-hidden state, click the
Solution Explorer tab again.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
15
The Splash Screen Application L E S S O N A

5. To permanently display the Solution Explorer window, click the Solution Explorer tab
and then click the Auto Hide (horizontal pushpin) button on the window’s title bar.
The vertical pushpin replaces the horizontal pushpin on the button.
6. If necessary, close the Data Sources window.
7. If necessary, click Form1.vb in the Solution Explorer window. If the items in the
Properties window do not appear in alphabetical order, click the Alphabetical button.
(Refer to Figure 1-6 for the button’s location.)
8. Figure 1-6 shows the current status of the windows in the IDE. Only the Windows Form
Designer, Solution Explorer, and Properties windows are open; the Toolbox window is
auto-hidden.

To reset the
window layout
in the IDE, click
Window on the
menu bar, click
Reset Window Layout,
and then click the Yes
button.

Alphabetical button

Figure 1-6   Current status of the windows in the IDE

In the next several sections, you will take a closer look at the Windows Form Designer, Solution
Explorer, and Properties windows. (The Toolbox window is covered in Lesson B.)

The Windows Form Designer Window


Figure 1-7 shows the Windows Form Designer window, where you create (or design) your
application’s graphical user interface, more simply referred to as a GUI. Only a Windows Form
object appears in the designer window shown in the figure. A Windows Form object, or form, is
the foundation for the user interface in a Windows application. You create the user interface by
adding other objects, such as buttons and text boxes, to the form.
Notice that a title bar appears at the top of the form. The title bar contains a default caption
(Form1) along with Minimize, Maximize, and Close buttons. At the top of the designer window
is a tab labeled Form1.vb [Design]. Form1.vb is the name of the file (on your computer’s hard
disk or on another device) that contains the Visual Basic instructions associated with the form,
and [Design] identifies the window as the designer window.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
16
CHAPTER 1 An Introduction to Visual Basic 2015

name of the disk file that


contains the instructions
associated with the form

title bar

form

Figure 1-7   Windows Form Designer window

Recall that As you learned in the Overview, all objects in an object-oriented program are instantiated
a class is a (created) from a class. A form, for example, is an instance of the Windows Form class. The form
­pattern that (an object) is automatically instantiated for you when you create a Windows application.
the computer
uses to create
an object. The Solution Explorer Window
The Solution Explorer window displays a list of the projects contained in the current solution
and the items contained in each project. Figure 1-8 shows the Solution Explorer window for
the Splash Solution, which contains one project named Splash Project. One of the items within
the project is a file named Form1.vb. The .vb extension on the filename indicates that the file is
a Visual Basic source file, which is a file that contains program instructions, called code. The
Form1.vb file contains the code associated with the form displayed in the designer window. You
can view the code using the Code Editor window, which you will learn about in Lesson B.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
17
The Splash Screen Application L E S S O N A

Figure 1-8   Solution Explorer window

The Form1.vb source file is referred to as a form file because it contains the code associated
with a form. The code associated with the first form included in a project is automatically stored
in a form file named Form1.vb. The code associated with the second form in the same project
is stored in a form file named Form2.vb, and so on. Because a project can contain many forms
and, therefore, many form files, it is a good practice to give each form file a more meaningful
name. Doing this will help you keep track of the various form files in the project. You can use the
Properties window to change the filename.

The Properties Window


Like everything in an object-oriented language, a file is an object. Each object has a set of To display the
attributes that determine its appearance and behavior. The attributes are called properties and properties of
are listed in the Properties window. When an object is created, a default value is assigned to the Form1.vb
each of its properties. The Properties window shown in Figure 1-9 lists the default values form file,
assigned to the properties of the selected object. (You do not need to size your Properties Form1.vb
window to match Figure 1-9.) must be selected in the
­Solution Explorer window.
The name of the selected object (in this case, the Form1.vb file) appears in the window’s
Object box. The window’s Properties list has two columns. The left column displays the
names of the selected object’s properties, which can be viewed either alphabetically or
by category. However, it’s usually easier to work with the Properties window when the
properties are listed in alphabetical order, as they are in Figure 1-9. The right column in
the Properties list is called the Settings box, and it displays the current value (or setting) of
each of the object’s properties. A brief description of the selected property appears in the
Description pane.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
18
CHAPTER 1 An Introduction to Visual Basic 2015

Object box
Categorized
Alphabetical button
button

Properties
list Settings box

Description
pane

Figure 1-9   Properties window

START H ERE To use the Properties window to change the form file’s name:

You can also 1. Form1.vb should be selected in the Solution Explorer window. Click File Name in the
change the File Properties list. Type Splash Form.vb and press Enter. (Be sure to include the .vb
Name property extension on the filename; otherwise, the computer will not recognize the file as a
by right-clicking source file.) Splash Form.vb appears in the Solution Explorer and Properties windows
Form1.vb in the and on the designer window’s tab, as shown in Figure 1-10.
Solution Explorer window
and then clicking Rename
on the context menu.

form file’s name

form file’s name

Figure 1-10   Form file’s name shown in various locations

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
19
Properties of a Windows Form LESSON A

Properties of a Windows Form


Like a file, a Windows form also has a set of properties. The form’s properties will appear in the
Properties window when you select the form in the designer window.
To view the properties of the form: STA R T HER E

1. Click the form in the designer window. Figure 1-11 shows a partial listing of the
properties of a Windows form.

location of the
Form class

form
class name
name

Figure 1-11   Properties window showing a partial listing of the form’s properties

Notice that Form1 System.Windows.Forms.Form appears in the Object box in Figure 1-11.
Form1 is the name of the form. The name is automatically assigned to the form when the form
is instantiated (created). In System.Windows.Forms.Form, Form is the name of the class used
to instantiate the form. System.Windows.Forms is the namespace that contains the Form class
definition. A class definition is a block of code that specifies (or defines) an object’s appearance
and behavior. All class definitions in Visual Basic 2015 are contained in namespaces, which you
can picture as blocks of memory cells inside the computer. Each namespace contains the code
that defines a group of related classes. The System.Windows.Forms namespace contains the
definition of the Windows Form class. It also contains the class definitions for objects you add to
a form, such as buttons and text boxes.
The period that separates each word in System.Windows.Forms.Form is called the dot member
access operator. Similar to the backslash (\) in a folder path, the dot member access operator
indicates a hierarchy, but of namespaces rather than folders. In other words, the backslash
in the path E:\VB2015\Chap01\Splash Solution\Splash Project\Splash Form.vb indicates
that the Splash Form.vb file is contained in (or is a member of ) the Splash Project folder,
which is a member of the Splash Solution folder, which is a member of the Chap01 folder, which
is a member of the VB2015 folder, which is a member of the E: drive. Likewise, the name
System.Windows.Forms.Form indicates that the Form class is a member of the Forms namespace,
which is a member of the Windows namespace, which is a member of the System namespace.
The dot member access operator allows the computer to locate the Form class in the computer’s
internal memory, similar to the way the backslash (\) allows the computer to locate the Splash
Form.vb file on your computer’s disk.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
20
CHAPTER 1 An Introduction to Visual Basic 2015

The Name Property


As you do to a form file, you should assign a more meaningful name to a Windows form
because doing so will help you keep track of the various forms in a project. But unlike a form
file, a Windows form has a Name property rather than a File Name property. You use the
name entered in an object’s Name property to refer to the object in code, so each object must
have a unique name. The name you assign to an object must begin with a letter and contain
only letters, numbers, and the underscore character. The name cannot include punctuation
characters or spaces.
There are several conventions for naming objects in Visual Basic. In this book, you will use
a naming convention called Hungarian notation. Names in Hungarian notation begin with
an ID of three (or more) characters that represents the object’s type, with the remaining
characters in the name representing the object’s purpose. For example, using Hungarian
notation, you might assign the name frmSplash to the current form. The “frm” identifies the
object as a form, and “Splash” reminds you of the form’s purpose. Hungarian notation names
are entered using camel case, which means you enter the ID characters in lowercase and
then capitalize the first letter of each subsequent word in the name. Camel case refers to the
fact that the uppercase letters appear as “humps” in the name because they are taller than the
lowercase letters.
STA RT H ERE To change the name of the form:
1. Drag the scroll box in the Properties window to the top of the vertical scroll bar. As you
scroll, notice the various properties associated with a form. Also notice that the items
within parentheses appear at the top of the Properties list.
2. Click (Name) in the Properties list. Type frmSplash and press Enter. The asterisk
(*) that now appears on the designer window’s tab indicates that the form has been
changed since the last time it was saved.

The Text Property


In addition to changing the form’s Name property, you should also change its Text property,
which controls the text displayed in the form’s title bar. Form1 is the default value assigned to
the Text property of the first form in a project. In this case, “Crighton Zoo” would be a more
descriptive value.
STA RT H ERE To set the Text property of the form:
1. Locate the Text property in the Properties list. Click Text. Type Crighton Zoo and
press Enter. The new text appears in the property’s Settings box and also in the form’s
title bar.
The Name and Text properties of a Windows form should always be changed to more
meaningful values. The Name property is used by the programmer when coding the
application. The Text property, on the other hand, is read by the user while the application
is running.

The StartPosition Property


When an application is started, the computer uses the form’s StartPosition property to
determine the form’s initial position on the screen. The frmSplash form represents a splash
screen, which typically appears in the middle of the screen.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
21
Setting and Restoring a Property’s Value LESSON A

To center a form on the screen when the application is started: STA R T HER E

1. Click StartPosition in the Properties list, click the list arrow in the Settings box, and
then click CenterScreen in the list.

The Font Property


A form’s Font property determines the type, style, and size of the font used to display the text
on the form. A font is the general shape of the characters in the text. Segoe UI, Tahoma, and
Microsoft Sans Serif are examples of font types. Font styles include regular, bold, and italic.
The numbers 9, 12, and 18 are examples of font sizes, which typically are measured in points,
with one point (pt) equaling 1/72 of an inch. The recommended font for applications created
for systems running Windows 8 is Segoe UI because it offers improved readability. Segoe is
pronounced “SEE-go,” and UI stands for user interface. For most of the elements in the interface,
you will use a 9pt font size. However, to make the figures in the book more readable, many of the
interfaces created in this book will use a larger font size.
To set the form’s Font property: STA R T HER E

1. Click Font in the Properties list and then click the … (ellipsis) button in the Settings
box to open the Font dialog box.
2. Locate and then click the Segoe UI font in the Font box. Click 9 in the Size box and
then click the OK button. (Do not be concerned if the size of the form changes.)

The Size Property


As you can with any Windows object, you can size a form by selecting it and then dragging the
sizing handles that appear around it. You can also size an object by selecting it and then pressing
and holding down the Shift key as you press the up, down, right, or left arrow key on your
keyboard. In addition, you can set the object’s Size property.
To set the form’s Size property: STA R T HER E

1. Click Size in the Properties list. The first number in the Setting box represents the
width of the form, measured in pixels. The second number represents the height, also
measured in pixels. A pixel, which is short for “picture element,” is one spot in a grid
of thousands of such spots that form an image either produced on the screen by a
computer or printed on a page by a printer.
2. Type 405, 340 and press Enter. Expand the Size property by clicking the plus box
that appears next to the property. Notice that the first number listed in the property
represents the width, and the second number represents the height. Click the minus
box to collapse the property.

Setting and Restoring a Property’s Value


In the next set of steps, you will practice setting and then restoring the value of the form’s
BackColor property, which determines the background color of the form.
To set and then restore the form’s BackColor property value: STA R T HER E

1. Click BackColor in the Properties list, click the list arrow, click the Custom tab, and
then click a red square to change the background color of the form to red.
2. Right-click BackColor in the Properties list and then click Reset on the context menu.
The background color of the form returns to its default setting. Figure 1-12 shows the
status of the form in the IDE.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
22
CHAPTER 1 An Introduction to Visual Basic 2015

the asterisk
indicates that
the form has
been changed
since the last
time it was
saved

Figure 1-12   Status of the form in the IDE

Saving a Solution
The Save All The asterisk (*) that appears on the designer tab in Figure 1-12 indicates that a change was made
button on to the form since the last time it was saved. It is a good idea to save the current solution every
the Standard 10 or 15 minutes so that you will not lose a lot of your work if a power outage unexpectedly
­toolbar looks occurs. You can save the solution by clicking File on the menu bar and then clicking Save All.
like this: . You can also click the Save All button on the Standard toolbar. When you save the solution,
the computer saves any changes made to the files included in the solution. It also removes the
asterisk that appears on the designer window’s tab.
STA RT H ER E To save the current solution:
1. Click File on the menu bar and then click Save All. The asterisk is removed from the
designer window’s tab, indicating that all changes made to the form have been saved.

Closing the Current Solution


When you are finished working on a solution, you should close it. Closing a solution closes all
projects and files contained in the solution.
STA RT H ER E To close the Splash Solution:
1. Click File on the menu bar. Notice that the menu contains a Close option and a Close
Solution option. The Close option closes the designer window in the IDE; however, it
does not close the solution itself. Only the Close Solution option closes the solution.
2. Click Close Solution. The Solution Explorer window indicates that no solution is
currently open in the IDE.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
23
Lesson A Summary L E S S O N A

Opening an Existing Solution


You can use the File menu to open an existing solution. The names of solution files end with .sln.
If a solution is already open in the IDE, you will be given the option of closing it before another
solution is opened.
To open the Splash Solution: STA R T HER E

1. Click File on the menu bar and then click Open Project to open the Open Project
dialog box.
2. Locate and then open the VB2015\Chap01\Splash Solution folder. Click Splash
Solution (Splash Solution.sln) in the list of filenames and then click the Open button.
(Depending on how Windows is set up on your computer, you may or may not see the
.sln extension on the filename. Refer to the Overview’s Summary section to learn how
to show/hide filename extensions.)
3. The Solution Explorer window indicates that the solution is open. If the designer
window is not open, right-click Splash Form.vb in the Solution Explorer window and
then click View Designer.

Exiting Visual Studio 2015


Finally, you will learn how to exit Visual Studio 2015. You will complete the splash screen in the
remaining two lessons. You can exit Visual Studio using either the Close button on its title bar or
the Exit option on its File menu.
To exit Visual Studio 2015: STA R T HER E

1. Click File on the menu bar and then click Exit.

Lesson A Summary
•• To start Visual Studio 2015:
Tap the Windows logo key (if necessary) to switch to the Windows 8 tile-based mode and
then click the Visual Studio 2015 tile.
•• To change the default environment settings:
Click Tools, click Import and Export Settings, select the Reset all settings radio button, click
the Next button, select the appropriate radio button, click the Next button, click the settings
collection you want to use, click the Finish button, and then click the Close button to close
the Import and Export Settings Wizard dialog box.
•• To reset the window layout in the IDE:
Click Window, click Reset Window Layout, and then click the Yes button.
•• To configure Visual Studio:
Click Tools, click Options, click the Projects and Solutions node, and then use the information
shown earlier in Figure 1-3 to select and deselect the appropriate check boxes. Next, expand
the Text Editor node, expand the All Languages node, click CodeLens, and then deselect
the Enable CodeLens check box. Finally, click the Debugging node, deselect the Step over
properties and operators (Managed only) check box, deselect the Show elapsed time PerfTip
while debugging check box, and then click the OK button to close the Options dialog box.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
24
CHAPTER 1 An Introduction to Visual Basic 2015

•• To create a Visual Basic 2015 Windows application:


Start Visual Studio 2015. Click File, click New Project, click the Visual Basic node, and then
click Windows Forms Application. Enter an appropriate name and location in the Name and
Location boxes, respectively. Select the Create directory for solution check box. Enter an
appropriate name in the Solution name box and then click the OK button.
•• To close and open a window in the IDE:
Close the window by clicking the Close button on its title bar. Use the appropriate option on
the View menu to open the window.
•• To auto-hide a window in the IDE:
Click the Auto Hide (vertical pushpin) button on the window’s title bar.
•• To temporarily display an auto-hidden window in the IDE:
Click the window’s tab.
•• To permanently display an auto-hidden window in the IDE:
Click the window’s tab to display the window, and then click the Auto Hide (horizontal
pushpin) button on the window’s title bar.
•• To set the value of a property:
Select the object whose property you want to set and then select the appropriate property
in the Properties list. Type the new property value in the selected property’s Settings box, or
choose the value from the list, color palette, or dialog box.
•• To give a more meaningful name to an object:
Set the object’s Name property.
•• To control the text appearing in the form’s title bar:
Set the form’s Text property.
•• To specify the starting location of the form:
Set the form’s StartPosition property.
•• To specify the type, style, and size of the font used to display text on the form:
Set the form’s Font property.
•• To size a form:
Drag the form’s sizing handles. You can also set the form’s Size, Height, and Width values in
the Properties window. In addition, you can select the form and then press and hold down
the Shift key as you press the up, down, left, or right arrow key on your keyboard.
•• To change the background color of a form:
Set the form’s BackColor property.
•• To restore a property to its default setting:
Right-click the property in the Properties list and then click Reset.
•• To save a solution:
Click File on the menu bar and then click Save All. You can also click the Save All button on
the Standard toolbar.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Random documents with unrelated
content Scribd suggests to you:
found, at a very moderate price, all that is most practical and
valuable in the former expensive edition, with a great accession
of new words and matter."—Author's Preface.

ANALECTA ANGLO-SAXONICA. Selections in Prose and Verse from


Anglo-Saxon Literature, with an Introductory Ethnological Essay, and
Notes, critical and explanatory. By LOUIS F. KLIPSTEIN, of the
University of Giessen, 2 thick vols. post 8vo. cloth, 12s. (original
price 18s.)

A DELECTUS IN ANGLO-SAXON, intended as a First Class-book in the


Language. By the Rev. W. BARNES, of St. John's College, Cambridge,
author of the Poems and Glossary in the Dorset Dialect. 12mo. cloth,
2s. 6d.

"To those who wish to possess a critical knowledge of their own


native English, some acquaintance with Anglo-Saxon is
indispensable; and we have never seen an introduction better
calculated than the present to supply the wants of a beginner in
a short space of time. The declensions and conjugations are
well stated, and illustrated by references to the Greek, Latin,
French, and other languages. A philosophical spirit pervades
every part. The Delectus consists of short pieces on various
subjects, with extracts from Anglo-Saxon History and the Saxon
Chronicle. There is a good Glossary at the end."—Athenæum,
Oct. 20, 1849.

FACTS AND SPECULATIONS ON THE ORIGIN AND HISTORY OF


PLAYING CARDS. By W. A. CHATTO, Author of "Jackson's History of
Wood Engraving," in one handsome vol. 8vo. illustrated with many
Engravings, both plain and coloured, cloth, 1l. 1s.

"It is exceedingly amusing."—Atlas.

"Curious, entertaining, and really learned book."—Rambler.


"Indeed the entire production deserves our warmest
approbation."—Literary Gazette.

"A perfect fund of Antiquarian research, and most interesting


even to persons who never play at cards."—Tait's Mag.

BIBLIOTHECA MADRIGALIANA: a Bibliographical account of the


Music and Poetical Works published in England in the Sixteenth and
Seventeenth Centuries, under the Titles of Madrigals, Ballets, Ayres,
Canzonets, &c. By DR. RIMBAULT. 8vo. cloth, 5s.

A DICTIONARY OF ARCHAIC AND PROVINCIAL WORDS, Obsolete


Phrases, Proverbs, and Ancient Customs from the reign of Edward I.
By JAMES ORCHARD HALLIWELL, F.R.S., F.S.A., &c. 2 vols. 8vo.
containing upwards of 1,000 pages closely printed in double
columns, cloth 1l. 1s.

It contains about 50,000 Words (embodying all the known scattered


Glossaries of the English language), forming a complete key to the
reading of the works of our old Poets, Dramatists, Theologians, and
other authors, whose works abound with allusions, of which
explanations are not to be found in ordinary Dictionaries and books
of reference. Most of the principal Archaisms are illustrated by
examples selected from early inedited MSS. and rare books, and by
far the greater portion will be found to be original authorities.

A LITTLE BOOK OF SONGS AND BALLADS, gathered from Ancient


Musick Books, MS. and Printed. By E. F. RIMBAULT, LL.D., &c. Post
8vo. pp. 240, half-bound in morocco, 6s.

——Antique Ballads, sung to crowds of old,


Now cheaply bought for thrice their weight in gold.

GUIDE TO THE ANGLO-SAXON TONGUE, with Lessons in Verse and


Prose, for the Use of Learners. By E. J. VERNON, B.A., Oxon. 12mo.
cloth, 5s. 6d.
* *
* This will be found useful as a Second Class-book, or to those well
versed in other languages.

Printed by Thomas Clark Shaw, of No. 8 New Street Square, at No. 5.


New Street Square, in the Parish of St. Bride, in the City of London;
and published by George Bell, of No. 186. Fleet Street, in the Parish
of St. Dunstan in the West, in the City of London, Publisher, at No.
186. Fleet Street aforesaid.—Saturday, January 1. 1853.
*** END OF THE PROJECT GUTENBERG EBOOK NOTES AND
QUERIES, NUMBER 166, JANUARY 1, 1853 ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like