Home > Store

Visual Basic 2015 in 24 Hours, Sams Teach Yourself

Register your product to gain access to bonus material or receive a coupon.

Visual Basic 2015 in 24 Hours, Sams Teach Yourself

Best Value Purchase

Book + eBook Bundle

  • Your Price: $39.89
  • List Price: $68.98
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

More Purchase Options

Book

  • Your Price: $27.99
  • List Price: $34.99
  • Usually ships in 24 hours.

eBook (Watermarked)

  • Your Price: $27.19
  • List Price: $33.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

About

Features

  • Teaches beginners everything they need to know to create applications using Visual Basic 2015
  • Shows how to build complete, reliable, and modern applications with Visual Basic 2015
  • Step-by-step guide through key elements for success as well as potential pitfalls as you build a robust application
  • Each lesson builds on the last, giving a strong, practical foundation for success

Description

  • Copyright 2016
  • Dimensions: 7" x 9-1/8"
  • Pages: 608
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-33745-2
  • ISBN-13: 978-0-672-33745-1

In just 24 sessions of one hour or less, you’ll learn how to build complete, reliable, and modern Windows applications with Microsoft® Visual Basic® 2015. Using a straightforward, step-by-step approach, each lesson builds on what you’ve already learned, giving you a strong foundation for success with every aspect of VB 2015 development.

Notes present interesting pieces of information.

Tips offer advice or teach an easier way to do something.

Cautions advise you about potential problems and help you steer clear of disaster.

Learn How To

  • Master VB 2015 by building a complete feature-rich application
  • Navigate VB 2015 and discover its new shortcuts
  • Work with objects, collections, and events
  • Build attractive, highly-functional user interfaces
  • Make the most of forms, controls, modules, and procedures
  • Efficiently store data and program databases
  • Make decisions in code
  • Use powerful object-oriented techniques
  • Work with graphics and text files
  • Manipulate filesystems and the Registry
  • Add email support
  • Create efficient modules and reusable procedures
  • Interact effectively with users
  • Write code to preview and print documents
  • Debug with VB 2015’s improved breakpoint features
  • Distribute your software

Download all examples and source code presented in this book from informit.com/title/9780672337451 as they become available.


Who Should Read This Book

Those who have little or no programming experience or who might be picking up Visual Basic as a second language.

Bug Alert

Description: Changing the startup form's name in a VB WinForms app does not update the "Startup form" #4517

Explanation: In the latest Visual Basic update on GitHub, Microsoft accidentally introduced a significant bug that you should be aware of. In the Visual Basic project properties dialog on one of the tabs (Application), is a drop down box for selecting the "startup object". This can be either a Main method or a System.Windows.Forms instance (or System.Windows.Window for WPF). When you do a rename on a form (say from the code editor in source or from the solution explorer) currently set as the startup form the rename doesn't cascade to the startup object project property cause the project to enter an invalid state where the user must now manually reset this project property from the now nonexistent Form to the new name. This is a huge annoyance.

The fix for the bug (until Microsoft addresses) can be found here:
http://www.jamesfo

Downloads

Downloads

Please download the code samples associated with STY Visual Basic 2015 in 24 Hours here.

Sample Content

Online Sample Chapter

Jumping in with Both Feet: A Visual Basic 2015 Programming Tour

Sample Pages

Download the sample pages (includes Chapter 1 and Index)

Table of Contents

Introduction . . . . . . . . . . . . . xvii

Part I: The Visual Basic 2015 Environment

Hour 1: Jumping in with Both Feet: A Visual Basic 2015 Programming Tour . 1

    Starting Visual Basic 2015 . . . . . . . . . . 2

    Creating a New Project . . . . . . . . . . 3

    Understanding the Visual Studio 2015 Environment . . . . . 6

    Changing the Characteristics of Objects . . . . . . . 7

    Adding Controls to a Form. . . . . . . . . 13

    Designing an Interface . . . . . . . . . . 15

    Writing the Code Behind an Interface. . . . . . . 20

    Running a Project . . . . . . . . . . . 24

    Summary . . . . . . . . . . . . 27

    Q&A . . . . . . . . . . . . . 28

    Workshop. . . . . . . . . . . . 28

    Exercises. . . . . . . . . . . . . 29

Hour 2: Navigating Visual Basic 2015 . . . . . . . . 31

    Using the Visual Basic 2015 Start Page . . . . . . . 31

    Navigating and Customizing the Visual Basic Environment . . . 34

    Working with Toolbars . . . . . . . . . . 40

    Adding Controls to a Form Using the Toolbox . . . . . . 41

    Setting Object Properties Using the Properties Window . . . . 43

    Managing Projects . . . . . . . . . . . 50

    A Quick-and-Dirty Programming Primer. . . . . . . 57

    Getting Help. . . . . . . . . . . . 59

    Summary . . . . . . . . . . . . 60

    Q&A . . . . . . . . . . . . . 60

    Workshop. . . . . . . . . . . . 61

    Exercises. . . . . . . . . . . . . 61

Hour 3: Understanding Objects and Collections . . . . . . 63

    Understanding Objects . . . . . . . . . . 64

    Understanding Properties. . . . . . . . . . 64

    Understanding Methods. . . . . . . . . . 72

    Building a Simple Object Example Project . . . . . . . 73

    Understanding Collections . . . . . . . . . 79

    Using the Object Browser . . . . . . . . . . 82

    Summary . . . . . . . . . . . . 84

    Q&A . . . . . . . . . . . . . 84

    Workshop. . . . . . . . . . . . 85

    Exercises. . . . . . . . . . . . . 85

Hour 4: Understanding Events . . . . . . . . . . 87

    Understanding Event-Driven Programming . . . . . . 87

    Building an Event Example Project . . . . . . . . 97

    Keeping Event Names Current . . . . . . . . 103

    Summary . . . . . . . . . . . . 103

    Q&A . . . . . . . . . . . . . 104

    Workshop. . . . . . . . . . . . 104

    Exercises. . . . . . . . . . . . 105

Part II: Building a User Interface

Hour 5: Building Forms: The Basics . . . . . . . . 107

    Changing a Form’s Name . . . . . . . . . 108

    Changing a Form’s Appearance . . . . . . . . 109

    Showing and Hiding Forms . . . . . . . . . 122

    Summary . . . . . . . . . . . . 128

    Q&A . . . . . . . . . . . . . 128

    Workshop. . . . . . . . . . . . 129

    Exercises. . . . . . . . . . . . 130

Hour 6: Building Forms: Advanced Techniques . . . . . . 131

    Working with Controls . . . . . . . . . . 131

    Creating Topmost Nonmodal Windows. . . . . . . 151

    Creating Transparent Forms . . . . . . . . . 151

    Creating Scrollable Forms . . . . . . . . . 152

    Creating MDI Forms . . . . . . . . . . 154

    Setting the Startup Form . . . . . . . . . 158

    Summary . . . . . . . . . . . . 159

    Q&A . . . . . . . . . . . . . 160

    Workshop. . . . . . . . . . . . 160

    Exercises. . . . . . . . . . . . 161

Hour 7: Working with Traditional Controls . . . . . . . 163

    Displaying Static Text with the Label Control. . . . . . 163

    Allowing Users to Enter Text Using a Text Box. . . . . . 164

    Creating Buttons. . . . . . . . . . . 172

    Creating Containers and Groups of Option Buttons . . . . . 176

    Displaying a List with the List Box . . . . . . . . 180

    Creating Drop-Down Lists Using the Combo Box . . . . . 188

    Summary . . . . . . . . . . . . 190

    Q&A . . . . . . . . . . . . . 191

    Workshop. . . . . . . . . . . . 191

    Exercises. . . . . . . . . . . . 192

Hour 8: Using Advanced Controls. . . . . . . . . 193

    Creating Timers . . . . . . . . . . . 193

    Creating Tabbed Dialog Boxes . . . . . . . . 197

    Storing Pictures in an Image List Control . . . . . . 200

    Building Enhanced Lists Using the List View Control . . . . 202

    Creating Hierarchical Lists Using the Tree View Control . . . . 207

    Summary . . . . . . . . . . . . 211

    Q&A . . . . . . . . . . . . . 212

    Workshop. . . . . . . . . . . . 212

    Exercises. . . . . . . . . . . . 213

Hour 9: Adding Menus and Toolbars to Forms . . . . . . 215

    Building Menus . . . . . . . . . . . 215

    Using the Toolbar Control . . . . . . . . . 229

    Creating a Status Bar . . . . . . . . . . 235

    Summary . . . . . . . . . . . . 237

    Q&A . . . . . . . . . . . . . 237

    Workshop. . . . . . . . . . . . 238

    Exercises. . . . . . . . . . . . 238

Part III: Making Things Happen—Programming

Hour 10: Creating and Calling Code Procedures . . . . . . 239

    Creating Visual Basic Code Modules . . . . . . . 239

    Writing Code Procedures . . . . . . . . . 242

    Calling Code Procedures . . . . . . . . . 248

    Exiting Procedures. . . . . . . . . . . 254

    Avoiding Infinite Recursion . . . . . . . . . 255

    Summary . . . . . . . . . . . . 256

    Q&A . . . . . . . . . . . . . 257

    Workshop. . . . . . . . . . . . 257

    Exercises. . . . . . . . . . . . 258

Hour 11: Using Constants, Data Types, Variables, and Arrays . . . . 259

    Understanding Data Types. . . . . . . . . 260

    Defining and Using Constants . . . . . . . . 263

    Declaring and Referencing Variables . . . . . . . 266

    Working with Arrays . . . . . . . . . . 273

    Determining Scope . . . . . . . . . . 276

    Declaring Variables of Static Scope . . . . . . . . 281

    Using Variables in Your Picture Viewer Project. . . . . . 282

    Renaming Variables . . . . . . . . . . 286

    Summary . . . . . . . . . . . . 287

    Q&A . . . . . . . . . . . . . 288

    Workshop. . . . . . . . . . . . 288

    Exercises. . . . . . . . . . . . 289

Hour 12: Performing Arithmetic, String Manipulation, and Date/Time Adjustments . .. 291

    Performing Basic Arithmetic Operations with Visual Basic . . . 291

    Comparing Equalities . . . . . . . . . . 295

    Understanding Boolean Logic. . . . . . . . . 296

    Manipulating Strings. . . . . . . . . . 298

    Working with Dates and Times . . . . . . . . 304

    Summary . . . . . . . . . . . . 309

    Q&A . . . . . . . . . . . . . 310

    Workshop. . . . . . . . . . . . 310

    Exercises. . . . . . . . . . . . 311

Hour 13: Making Decisions in Visual Basic Code . . . . . . 313

    Making Decisions Using If...Then. . . . . . . 313

    Branching Within a Procedure Using GoTo . . . . . . 324

    Summary . . . . . . . . . . . . 326

    Q&A . . . . . . . . . . . . . 327

    Workshop. . . . . . . . . . . . 327

    Exercises. . . . . . . . . . . . 328

Hour 14: Looping for Efficiency . . . . . . . . . 329

    Looping a Specific Number of Times Using For...Next . . . . 329

    Using Do...Loop to Loop an Indeterminate Number of Times . . . 336

    Summary . . . . . . . . . . . . 341

    Q&A . . . . . . . . . . . . . 341

    Workshop. . . . . . . . . . . . 342

    Exercises. . . . . . . . . . . . 342

Hour 15: Debugging Your Code . . . . . . . . . 343

    Adding Comments to Your Code . . . . . . . . 344

    Identifying the Two Basic Types of Errors . . . . . . 346

    Using Visual Basic’s Debugging Tools . . . . . . . 349

    Breaking Only When a Condition Is Met. . . . . . . 358

    Breaking Only When a Breakpoint Is Hit a Certain Number of Times . 359

    Sending Messages to the Output Window Using Tracepoints. . . 360

    Writing an Error Handler Using Try...Catch...Finally . . . 360

    Summary . . . . . . . . . . . . 368

    Q&A . . . . . . . . . . . . . 368

    Workshop. . . . . . . . . . . . 368

    Exercises. . . . . . . . . . . . 369

Hour 16: Designing Objects Using Classes . . . . . . . 371

    Understanding Classes. . . . . . . . . . 372

    Instantiating Objects from Classes . . . . . . . . 381

    Summary . . . . . . . . . . . . 388

    Q&A . . . . . . . . . . . . . 388

    Workshop. . . . . . . . . . . . 388

    Exercises. . . . . . . . . . . . 389

Hour 17: Interacting with Users . . . . . . . . . 391

    Displaying Messages Using the MessageBox.Show() Function. . . 391

    Creating Custom Dialog Boxes. . . . . . . . 398

    Using InputBox() to Get Information from a User . . . . . 401

    Interacting with the Keyboard . . . . . . . . 404

    Using the Common Mouse Events . . . . . . . . 406

    Summary . . . . . . . . . . . . 409

    Q&A . . . . . . . . . . . . . 410

    Workshop. . . . . . . . . . . . 410

    Exercises. . . . . . . . . . . . 411

Hour 18: Working with Graphics . . . . . . . . . 413

    Understanding the Graphics Object . . . . . . . 413

    Working with Pens . . . . . . . . . . 416

    Using System Colors . . . . . . . . . . 417

    Working with Rectangles . . . . . . . . . 421

    Drawing Shapes . . . . . . . . . . . 422

    Drawing Text . . . . . . . . . . . 423

    Persisting Graphics on a Form . . . . . . . . 425

    Building a Graphics Project Example . . . . . . . 425

    Summary . . . . . . . . . . . . 432

    Q&A . . . . . . . . . . . . . 432

    Workshop. . . . . . . . . . . . 432

    Exercises. . . . . . . . . . . . 433

Part IV: Working with Data

Hour 19: Performing File Operations . . . . . . . . 435

    Using the OpenFileDialog and SaveFileDialog Controls . . . 435

    Manipulating Files with the File Object. . . . . . . 443

    Manipulating Directories with the Directory Object . . . . 452

    Summary . . . . . . . . . . . . 453

    Q&A . . . . . . . . . . . . . 454

    Workshop. . . . . . . . . . . . 454

    Exercises. . . . . . . . . . . . 455

Hour 20: Working with the Registry and Text Files . . . . . . 457

    Working with the Registry . . . . . . . . . 457

    Reading and Writing Text Files . . . . . . . . 470

    Summary . . . . . . . . . . . . 480

    Q&A . . . . . . . . . . . . . 481

    Workshop. . . . . . . . . . . . 481

    Exercises. . . . . . . . . . . . 482

Hour 21: Working with a Database . . . . . . . . 483

    Introducing ADO.NET . . . . . . . . . . 484

    Manipulating Data . . . . . . . . . . 491

    Summary . . . . . . . . . . . . 502

    Q&A . . . . . . . . . . . . . 502

    Workshop. . . . . . . . . . . . 503

    Exercises. . . . . . . . . . . . 503

Hour 22: Printing . . . . . . . . . . . . 505

    Preparing the Picture Viewer Project . . . . . . . 506

    Printing and Previewing a Document . . . . . . . 509

    Changing Printer and Page Settings . . . . . . . 519

    Scaling Images to Fit a Page . . . . . . . . . 522

    Summary . . . . . . . . . . . . 527

    Q&A . . . . . . . . . . . . . 528

    Workshop. . . . . . . . . . . . 528

    Exercises. . . . . . . . . . . . 528

Hour 23: Sending Emails. . . . . . . . . . 529

    Understanding the Classes Used to

    Send Emails . . . . . . . . . . . . 530

    Sending Email from Your Picture Viewer Application . . . . 530

    Summary . . . . . . . . . . . . 543

    Q&A . . . . . . . . . . . . . 544

    Workshop. . . . . . . . . . . . 544

    Exercises. . . . . . . . . . . . 544

Part V: Deploying Solutions and Beyond

Hour 24: Deploying Applications . . . . . . . . . 545

    Understanding ClickOnce Technology. . . . . . . 545

    Using the Publish Wizard to Create a ClickOnce Application . . . 547

    Testing Your Picture Viewer ClickOnce Install Program . . . . 552

    Uninstalling an Application You’ve Distributed . . . . . 553

    Setting Advanced Options for Creating ClickOnce Programs. . . 556

    Summary . . . . . . . . . . . . 557

    Q&A . . . . . . . . . . . . . 557

    Workshop. . . . . . . . . . . . 557

    Exercises. . . . . . . . . . . . 558

Appendix A: The 10,000-Foot View . . . . . . . . 559

TOC, 9780672337451, 7/19/2015

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020