My Cart (0)

Customer Service 1-800-221-5528

Murach’s Visual Basic 2012

by Anne Boehm
26 chapters, 876 pages, 379 illustrations
Published November 2013
ISBN 978-1-890774-73-8
Print: $43.60
List Price: $54.50 Save 20%
eBook: $35.60
List Price: $44.50 Save 20%
Print + eBook: $51.60
List Price: $64.50 Save 20%

This is the latest edition of our best-selling and much-loved Visual Basic book. It focuses on how to develop professional Windows Forms applications with Visual Basic. But along the way, it teaches you the Visual Basic language and core skills that you’ll use to develop any Visual Basic application...whether for Windows, the web, or mobile devices.

College Instructors

Go to our instructor’s site to learn more about this book and its instructor’s materials.

 

With detailed coverage of IDE best practices, end-of-chapter exercises, non-trivial sample applications, and the unique paired-page format, Murach's Visual Basic will have you building professional-level, real-world applications in no time."

Jeff Manley, a1vbcode.com

  • About this Book
  • Table of Contents
  • FREE Downloads
  • Book FAQs
  • Corrections
  • Reviews

Who this book is for

This book is for anyone who wants to learn how to use Visual Basic 2012 to develop Windows Forms applications.

  • It works if you’re new to programming.
  • It works if you’re new to Microsoft’s .NET development environment.
  • It works if you’re an experienced .NET developer who’s new to Visual Basic.
  • It works if you have programming experience with another language like Java, C++, or COBOL.
  • And it works if you’ve already read 3 or 4 other Visual Basic books and still don’t know how to develop a real-world business application.

What you’ll learn in this book

The short answer is: Everything you need to know to develop Windows applications at a professional level. But here’s a section-by-section summary.

Section 1: Get started fast

In this first section of the book, you’ll learn how to use Visual Studio and Visual Basic to develop a simple Windows application. That will get you off to a fast start and prepare you for rapid progress in the sections that follow.

Section 2: The Visual Basic essentials

Data types, control structures, the core .NET classes, and all of the other language essentials...it’s all in this section. Along the way, you’ll learn how to do the tasks that are required by professional business applications, like data validation. You’ll also learn how to create and use your own business and database classes so your applications will be object-oriented.

Section 3: Database programming

This section teaches the basic skills for developing database applications. To start, you’ll learn how to use data sources to build database applications faster than ever. This is particularly useful for developing small, relatively simple applications and for prototyping larger applications. Then, you’ll learn how to write ADO.NET code that directly accesses the database.

Section 4: Object-oriented programming

This section presents the object-oriented programming features of the Visual Basic language that weren’t presented in section 2. Here, you’ll learn how to use inheritance, polymorphism, interfaces, and much more.

Section 5: More skills for working with data

This section shows how to work with text, binary, and XML files. It also show how to work with LINQ, a feature that lets you query most any data source using the Visual Basic language.

Section 6: Enhancement, deployment, and Windows 8

This section shows how to enhance a Windows interface with a multiple-document interface (MDI), menus, toolbars, status bars, and help information…all the finishing touches that make your applications thoroughly professional. Then, to complete your training, you’ll learn three ways to deploy your applications.

As a bonus, the last chapter introduces you to Windows 8 application development. That includes the special design considerations for Windows 8 apps along with the basic skills for developing these apps and submitting them to the Windows Store.

What’s new in this edition

Frankly, not much has changed when it comes to using Visual Basic and Visual Studio to develop Windows applications.

However, Windows 8 programming is coming of age, so we’ve added an introductory chapter on developing Windows 8 apps. This chapter presents the special design considerations that are involved, along with the basic skills for building Windows 8 apps and submitting them to the Windows Store for public access.

What software you need for this book

Option #1: Full editions of Visual Studio 2012

To develop Visual Basic applications, you can use any of the full editions of Visual Studio 2012, including the Professional Edition, the Premium Edition, or the Ultimate Edition. All of these come with everything you need to develop Visual Basic 2012 applications, including the Visual Studio development environment, version 4.5 of the Microsoft .NET Framework, Visual Basic 2012, and a simplified version of SQL Server called SQL Server 2012 Express LocalDB.

Option #2: Free edition for Windows desktop programming

To develop Windows Forms applications, you can download a free, simplified edition of the Visual Studio software from Microsoft’s website:

Visual Studio Express 2012 for Windows Desktop

Like the full editions, this Express edition includes the Visual Studio development environment, version 4.5 of the Microsoft .NET Framework, Visual Basic 2012, and SQL Server 2012 Express LocalDB.

Although the Express edition has a few differences from the full editions, this book carefully notes those differences. The good news is that all the skills that you learn with the Express edition will still work when you’re using one of the full editions on the job.

What people say about this book

"With detailed coverage of IDE best practices, end-of-chapter exercises, non-trivial sample applications, and the unique paired-page format, Murach's Visual Basic will have you building professional-level, real-world applications in no time."
-- Jeff Manley, a1vbcode.com

"I must say, your claims that your books are great training material are right on spot! I was an experienced Visual Basic programmer years ago before I changed the focus of my career. Now, returning to the programming field, I found myself completely lost and overwhelmed with the changes. Your Visual Basic book has put me back on track and cleared up some rather murky areas for me. Thank you so much!"
-- Aaron Ross, IS Technical Specialist, TSTech Indiana LLC

"The one best thing that sets the Murach books apart is the complete application given at the end of the chapter. It's difficult to learn a new language by just working with snippets of code. Murach puts together an entire business application to demonstrate the concepts of the chapter, and this more than anything else will help the programmer on the job."
-- Marvin Schneider, Developer/College Instructor, New York

“Visual Basic is not the hardest of languages, but this book definitely makes it understandable for everyone. Very good theory/practice layout, introduces you to the basics and takes you further so it is a suitable book for beginners AND experienced Visual Basic programmers. Really recommend this if you want to get more out of your VB.NET experience :).”
-- Posted at an online bookseller

“If you need rapid learning programs and you have knowledge of programming, this book is for you, because the right page has a summary of the left page where you can use it as reference. I love it.”
-- Posted at an online bookseller

"A GOLD MINE ON VB .NET!! Overall, I can tell you this book is easy to read, easy to understand.... The application with data validation: A complete REAL EXAMPLE ready to use for your own application. I love the fact it shows a generic approach (reusable).... This is my first Murach's book and certainly won't be the last one."
-- Posted at an online bookseller

"If you haven't tried Mike Murach's style in software books, you're in for a real treat! They have a style and format unique in the publishing world.... If you're in the market for a book that will do the best job possible of helping you learn VB.NET, you can't do better!"
-- Dan Mabbutt, About Visual Basic.com

View the table of contents for this book in a PDF: Table of Contents (PDF)

Click on any chapter title to display or hide its content.

Section 1 Introduction to Visual Basic programming

Chapter 1 An introduction to Visual Studio

An introduction to .NET development

.NET applications

Visual Studio and the .NET programming languages

What about Visual Studio 2013?

The .NET Framework

The Visual Studio IDE

How a Visual Basic application is compiled and run

How Visual Basic differs from the other .NET languages

A tour of the Visual Studio IDE

How to start Visual Studio

How to open or close an existing project

Some possible menu variations

How to use the Form Designer

How to use the Code Editor

How to use the Solution Explorer

How to work with Visual Studio’s windows

How to test a project

How to build a project

How to run a project

How to upgrade projects and change .NET Framework versions

How to upgrade projects created in earlier versions of Visual Basic

How to change the .NET Framework version used by a project

Chapter 2 How to design a Windows Forms application

How to set options and create a new project

How to set the Visual Studio options

How to change the environment settings

How to create a new project

How to design a form

The design of the Invoice Total form

How to add controls to a form

How to set properties

Common properties for forms and controls

How to add navigation features

The property settings for the Invoice Total form

How to use Document Outline view

How to name and save the files of a project

How to name the files of a project

How to save the files of a project

Chapter 3 How to code and test a Windows Forms application

An introduction to coding

Introduction to object-oriented programming

How to refer to properties, methods, and events

How an application responds to events

How to add code to a form

How to create an event handler for the default event of a form or control

How IntelliSense helps you enter the code for a form

Coding rules for Visual Basic statements

The event handlers for the Invoice Total form

How to code with a readable style

How to code comments

How to detect and correct syntax errors

Other skills for working with code

How to use the toolbar buttons

How to collapse or expand code

How to zoom in and out

How to print the source code

How to use code snippets

How to rename identifiers

How to use the Smart Compile Auto Correction feature

How to use the My feature

How to get help information

How to run, test, and debug a project

How to run a project

How to test a project

How to debug runtime errors

Section 2 The Visual Basic language essentials

Chapter 4 How to work with numeric and string data

How to work with the built-in value types

The built-in value types

How to declare and initialize variables

How to declare and initialize constants

How to code arithmetic expressions

How to code assignment statements

How to work with the order of precedence

How to use casting

How to change the type semantics

How to use the Math class

How to work with strings

How to declare and initialize a string

How to join and append strings

How to convert data types

The .NET structures and classes that define data types

How to use Visual Basic functions to convert data types

How to use methods of the .NET data structures to convert data types

How to use methods of the Convert class to convert data types

How to use three of the formatting functions

How to use methods to convert numbers to formatted strings

Three other skills for working with data

How to work with scope

How to declare and use enumerations

How to work with nullable types

Two versions of the Invoice Total application

The basic Invoice Total application

The enhanced Invoice Total application

Chapter 5 How to code control structures

How to code Boolean expressions

How to use the relational operators

How to use the logical operators

How to code conditional statements

How to code If statements

How to code Select Case statements

An enhanced version of the Invoice Total application

How to code loops

How to code For loops

How to code Do loops

How to use Exit and Continue statements

Debugging techniques for programs with loops

The Future Value application

The design and property settings for the form

The code for the form

Chapter 6 How to code procedures and event handlers

How to code and call procedures

How to code Sub procedures

How to call Sub procedures

When and how to pass arguments by reference and by value

How to code and call Function procedures

How to use optional parameters

How to work with events

How to start an event handler for any event

How to handle multiple events with one event handler

How to use the Code Editor to start an event handler

How to add and remove event wiring

Another version of the Future Value application

The Function procedure

The event handlers

Chapter 7 How to handle exceptions and validate data

An introduction to data validation and exception handling

How to use the IsNumeric function for data validation

How to display a dialog box for error messages

How exception handling works

How to use structured exception handling

How to catch an exception

How to use the properties and methods of an exception

How to catch specific types of exceptions

How to throw an exception

The Future Value application with exception handling

How to validate data

How to validate a single entry

How to use generic procedures to validate an entry

How to validate multiple entries

The Future Value application with data validation

The dialog boxes

The code

Two other ways to validate data

How to use the Validating event

How to use the masked text box

Chapter 8 How to work with arrays and collections

How to work with one-dimensional arrays

How to create an array

How to assign values to the elements of an array

How to use For loops to work with arrays

How to use For Each loops to work with arrays

How to work with rectangular arrays

How to create a rectangular array

How to assign values to a rectangular array

How to work with rectangular arrays

How to work with jagged arrays

How to create a jagged array

How to assign values to a jagged array

How to work with jagged arrays

More skills for working with arrays

How to use the Array class

How to refer to, copy, and resize arrays

How to code procedures that work with arrays

How to work with collections

Commonly used collection classes

Typed vs. untyped collections

How to work with a list

How to work with a sorted list

How to work with queues and stacks

How to work with an array list

Chapter 9 How to work with dates and strings

How to work with dates and times

How to create a DateTime value

How to get the current date and time

How to format DateTime values

How to get information about dates and times

How to perform operations on dates and times

How to use Visual Basic properties and functions to work with dates and times

How to work with strings

The properties and methods of the String class

Code examples that work with strings

More examples that work with strings

Two procedures for validating user entries

How to use the StringBuilder class

How to use Visual Basic functions to work with strings

How to format numbers, dates, and times

How to format numbers

How to format dates and times

Chapter 10 More skills for working with Windows forms and controls

How to work with controls

Five more types of controls

How to work with combo boxes and list boxes

How to work with check boxes and radio buttons

How to work with group boxes

How to use Tab Order view to set the tab order

How to get the information you need for using a control

How to work with multi-form projects

How to add a form to a project

How to rename a form

How to change the startup form for a project

How to display a form as a dialog box

How to pass data between a form and a custom dialog box

How to use the MessageBox class

How to display a dialog box and get the user response

How to use the FormClosing event

The Payment application

The operation

The property settings

The code for the Customer form

The code for the Payment form

Chapter 11 How to create and use classes

An introduction to classes

How classes can be used to structure an application

The members you can define within a class

The code for the Product class

How instantiation works

How to create a class

How to add a class file to a project

How to code fields

How to code standard properties

How to code auto-implemented properties

How to code methods

How to code constructors

How to code shared members

How to generate code stubs

The Product Maintenance application

The operation of the Product Maintenance application

The classes used by the Product Maintenance application

The code for the Product Maintenance application

How to browse classes and use class diagrams

How to browse the classes in a solution

How to use class diagrams and the Class Details window

How to work with structures

How to create a structure

How to use a structure

Chapter 12 How to debug an application

Basic debugging techniques

How to set the debugging options

How to work in break mode

How to use the Edit and Continue feature

How to work with data tips

How to use breakpoints

How to control the execution of an application

How to use the debugging windows

How to use the Locals window to monitor variables

How to use the Autos window to monitor variables

How to use Watch windows to monitor expressions

How to use the Immediate window to execute commands

How to use the Call Stack window to monitor called procedures

How to use the Call Hierarchy window to navigate through your code

How to use the Output or Immediate window to get build or debugging information

How use the Visualizer dialog boxes to view strings

Section 3 Database programming

Chapter 13 An introduction to database programming

An introduction to client/server systems

The hardware components of a client/server system

The software components of a client/server system

An introduction to relational databases

How a table is organized

How the tables in a database are related

How the columns in a table are defined

The design of the MMABooks database

How to use SQL to work with a relational database

How to query a single table

How to join data from two or more tables

How to add, update, and delete data in a table

An introduction to ADO.NET

The .NET data providers

How the basic ADO.NET components work

Concurrency and the disconnected data architecture

How a dataset is organized

How to work with data without using a data adapter

Two ways to create ADO.NET objects

Chapter 14 How to work with data sources and datasets

How to create a data source

How to use the Data Sources window

How to start the Data Source Configuration Wizard

How to choose a data source type

How to choose the database model for a data source

How to choose the connection for a data source

How to create a connection to a database

How to save a connection string in the App.config file

How to choose database objects for a data source

The schema file created by the Data Source Configuration Wizard

How to use a data source

How to generate a DataGridView control from a data source

A Product Maintenance application that uses a DataGridView control

How to change the controls associated with a data source

How to generate detail controls from a data source

A Customer Maintenance application that uses TextBox controls

How to handle data errors

How to handle data provider errors

How to handle ADO.NET errors

How to handle data errors for a DataGridView control

How to use the Dataset Designer

How to view the schema for a dataset

How to use the Query Builder

How to preview the data for a query

How to interpret the generated SQL statements

Chapter 15 How to work with bound controls and parameterized queries

How to work with bound text boxes and combo boxes

How to format the data displayed in a text box

How to bind a combo box to a data source

How to use code to work with a binding source

How to work with parameterized queries

How to create a parameterized query

How to use code to work with a parameterized query

How to work with the ToolStrip control

How to use the Items Collection Editor

How to code an event handler for a ToolStrip item

An enhanced Customer Maintenance application

The user interface

The code

How to work with a DataGridView control

How to modify the properties of a DataGridView control

How to edit the columns of a DataGridView control

How to format the data in the columns of a DataGridView control

How to use a DataGridView control to create a Master/Detail form

A Customer Invoice Display application

The user interface

The dataset schema

The code for the Customer Invoices form

Chapter 16 How to use ADO.NET to write your own data access code

How to work with connections and commands

How to create and work with connections

How to create and work with commands

How to create and work with parameters

How to use parameters in SQL statements

How to create parameters

How to work with parameters

How to execute commands

How to create and work with a data reader

How to execute queries that return a single value

How to execute action queries

A Customer Maintenance application that uses commands

The user interface

The class diagram for the business and database classes

The code for the CustomerDB class

The code for the StateDB class

The code for the MMABooksDB class

The code for the Customer Maintenance form

The code for the Add/Modify Customer form

Section 4 Object-oriented programming

Chapter 17 How to work with default properties, events, and operators

An introduction to the ProductList class

The code for a simple ProductList class

The specifications for the enhanced ProductList class

How to work with default properties

How to create a default property

How to throw an argument exception

How to work with events

How to define events

How to use events

How to overload operators

An introduction to operator overloading

How to overload arithmetic operators

How to overload relational operators

An enhanced version of the Product Maintenance application

The code for the ProductList class

The code for the Product Maintenance form

Chapter 18 How to work with inheritance

An introduction to inheritance

How inheritance works

How the .NET Framework uses inheritance

Methods inherited from the System.Object class

How to use inheritance in your applications

Basic skills for working with inheritance

How to create a base class

How to create a derived class

How polymorphism works

An inheritance version of the Product Maintenance application

The operation of the Product Maintenance application

The code for the Product, Book, and Software classes

The code for the ProductList class

The code for the Product Maintenance form

The code for the New Product form

Object types and casting

How to use the Type class to get information about an object’s type

How to use casting with inheritance

How to work with abstract and sealed classes

How to work with abstract classes

How to work with sealed classes

Chapter 19 How to work with interfaces and generics

How to work with interfaces

An introduction to interfaces

Some of the interfaces defined by the .NET Framework

How to create an interface

How to implement an interface

A Product class that implements the ICloneable interface

How to use an interface as a parameter

How to work with generics

How to code a class that defines a generic collection

Some of the generic interfaces defined by the .NET Framework

How to implement the IComparable() interface

How to use constraints

How to code an interface that uses generics

Chapter 20 How to organize and document your classes

How to organize your classes

How to code multiple classes in a single file

How to split a single class across multiple files

How to work with namespaces

How to document your classes

How to add XML documentation to a class

How to view the XML documentation

How to create and use class libraries

How class libraries work

How to create a class library project

How to add a reference to a class library

How to use the classes in a class library

Section 5 More skills for working with data

Chapter 21 How to work with files and data streams

An introduction to the System.IO classes

The classes for managing directories, files, and paths

How files and streams work

How to use the FileStream class

How to use the exception classes for file I/O

How to use the My.Computer.FileSystem object

How to work with text files

How to write a text file

How to read a text file

A class that works with a text file

How to work with binary files

How to write a binary file

How to read a binary file

A class that works with a binary file

Chapter 22 How to work with XML files

An introduction to XML

An XML document

XML tags, declarations, and comments

XML elements

XML attributes

How to work with the XML Editor

How to create a new XML file

How to open an existing XML file

How to edit an XML file

How to work with XML

How to use the XmlWriter class

Code that writes an XML document

How to use the XmlReader class

How the XmlReader class reads nodes

Code that reads an XML document

A class that works with an XML file

Chapter 23 How to use LINQ

Basic concepts for working with LINQ

How LINQ is implemented

Advantages of using LINQ

The three stages of a query operation

How to code a LINQ query

How to identify the data source for a query

How to filter the results of a query

How to sort the results of a query

How to select fields from a query

How to join data from two or more data sources

A Customer Invoice application that uses generic lists

The user interface

The code for the form

A Customer Invoice application that uses a typed dataset

The dataset schema

The code for the form

Section 6 Enhancement, deployment, and Windows 8

Chapter 24 How to enhance the user interface

Two types of user interfaces

A single-document interface (SDI)

A multiple-document interface (MDI)

How to develop SDI applications

How to use a startup form

How to use a Tab control

How to add menus to a form

How to create menus

How to set the properties that work with menu items

How to write code that works with menu items

How to develop MDI applications

How to create parent and child forms

How to write code that works with parent and child forms

How to add toolbars to a form

How to create a toolbar

How to write code that works with toolbars

How to create and use a status bar

How to create a simple status bar

How to create a status bar with multiple panels

How to work with modules

How to create and code a module

How to use a Main procedure

How to add help information

How to add tool tips

How to add context-sensitive help

Chapter 25 How to deploy an application

An introduction to deploying Windows applications

How XCopy works

How ClickOnce works

How a Setup program works

How to use XCopy

How to create a release build

How to copy the release build to the client

How to use ClickOnce

How to publish an application

How to select the files that are published

How to select the prerequisites

How to set the update options

How to set the publish options

How to install an application

How to update an application

How to create and use a Setup program

How to create an InstallShield project

How to use the InstallShield Project Assistant

How to add output files to an InstallShield project

How to create and view the installation files for a Setup program

How to use a Setup program to install an application

How to deploy database applications

Using ClickOnce deployment

Using a Setup program

Chapter 26 An introduction to Windows 8 programming

Windows 8 design concepts

Microsoft design principles for Windows Store apps

How to use the app bar

How to use the nav bar

How to use the charms

The four application view states

The Financial Calculations application for Windows 8

The user interface

The XAML for the Menu page

The XAML for the Future Value page

The XAML for the Depreciation page

The event handlers for the Menu page

The event handlers for the Future Value page

The event handlers for the Depreciation page

Visual Studio features for developing Windows Store apps

The Windows Store app project templates

How to use the XAML Designer

How to use Blend for Visual Studio

How to use the Visual Studio simulator

How to submit an app to the Windows Store

Appendixes

Appendix A How to install and use the software for this book

How to use the downloadable files

How to install Visual Studio 2012

How to use the MMABooks database

Sample chapters

Chapter 2: How to design a Windows Forms application

This chapter shows you how to use Visual Studio 2012 to design a Windows form that displays the discount amount and final total for an invoice, based on user input and a fixed discount rate. It also tells you how to set the Visual Studio options so it’s easier to create a new project.

Chapter 3: How to code and test a Windows Forms application

This chapter teaches you how to enter the Visual Basic code for the Windows form in chapter 2 so the interface works the way you want it to. It also gets you started with practical debugging techniques.

Chapter 2 PDF (0.7Mb) Download Now

Chapter 3 PDF (1.2MB) Download Now

The book applications and exercises

This download includes:

  • The source code and data for the applications that are presented in the book
  • The starting source code and data for the exercises in the book
  • The solutions to the book exercises so you can check your work

The appendix in the book shows how to install and use these files.

Exe file for Windows (25.1Mb) Download Now

Zip file for any system (25.1Mb) Download Now

Below are the answers to the questions that have come up most often about this book. If you have any questions that aren’t answered here, please email us. Thanks!

Can I use Visual Studio 2013 with this book?

Yes, you can. The changes in Visual Studio 2013 don’t affect the Visual Basic fundamentals that are covered in this book. Just be aware that the appearance of the interface has changed; the functions are the same, but they look different.

To view the corrections for this book in a PDF, just click on this link: View the corrections

Then, if you find any other errors, please email us so we can correct them in the next printing of the book. Thank you!

There are no reviews for this product yet.

To leave a review, please log in to your account.     Log In Here

Our Ironclad Guarantee

You must be satisfied. Try our books for 60 days. They must be the best you've ever used or send them back for a prompt refund. No questions asked!

Contact Murach Books

For orders and customer service:

1-800-221-5528

Weekdays, 8 to 4 Pacific Time

College Instructors

If you're a college instructor who would like to consider a book for a course, please visit our website for instructors to learn how to get a complimentary review copy and the full set of instructional materials.