Visual Basic® 2012 How to Program, Sixth Edition

Book description

Appropriate for all basic-to-intermediate level courses in Visual Basic 2012 programming. Visual Basic 2012 How to Program, Sixth Edition is also appropriate for anyone interested in learning programming with Visual Basic 2012.

Created by world-renowned programming instructors Paul and Harvey Deitel, Visual Basic 2012 How to Program, Sixth Edition introduces all facets of the Visual Basic 2012 language through a hands-on approach with hundreds of working programs. This book has been thoroughly updated to reflect the major innovations Microsoft has incorporated in Visual Basic 2012; all discussions and sample code have been carefully audited against the newest Visual Basic language specification. The Sixth Edition is updated to Visual Studio 2012 and includes new chapters on Windows 8 UI app development, Windows 8 graphics/multimedia, Windows Phone 8 app development and Windows Azure.

Readers begin by getting comfortable with the free Visual Basic Express 2012 IDE and basic VB syntax. Next, they build their skills one step at a time, mastering control structures, classes, objects, methods, variables, arrays, and the core techniques of object-oriented programming. With this strong foundation in place, the Deitels introduce more sophisticated techniques, including inheritance, polymorphism, exception handling, strings, GUI's, data structures, generics, and collections. Throughout, the authors show developers how to make the most of Microsoft’s Visual Studio tools. A series of appendices provide essential programming reference material on various topics.

Table of contents

  1. Title Page
  2. Copyright Page
  3. Dedication Page
  4. Trademarks
  5. Brief Contents
  6. Contents
  7. Preface
  8. Before You Begin
  9. 1 Introduction to Computers, the Internet and Visual Basic
    1. 1.1 Introduction
    2. 1.2 Hardware and Moore’s Law
    3. 1.3 Data Hierarchy
    4. 1.4 Computer Organization
    5. 1.5 Machine Languages, Assembly Languages and High-Level Languages
    6. 1.6 Object Technology
    7. 1.7 Internet and World Wide Web
    8. 1.8 Visual Basic
    9. 1.9 Microsoft’s .NET
    10. 1.10 Microsoft’s Windows® Operating System
    11. 1.11 Windows Phone 8 for Smartphones
    12. 1.12 Windows Azure™ and Cloud Computing
    13. 1.13 Visual Studio Integrated Development Environment
    14. 1.14 Test-Driving the Visual Basic Advanced Painter App in Visual Studio 2012
  10. 2 Dive Into® Visual Studio Express 2012 for Windows Desktop
    1. 2.1 Introduction
    2. 2.2 Overview of the Visual Studio 2012 IDE
    3. 2.3 Menu Bar and Toolbar
    4. 2.4 Navigating the Visual Studio IDE
    5. 2.5 Using Help
    6. 2.6 Using Visual App Development to Create a Simple App that Displays Text and an Image
    7. 2.7 Wrap-Up
    8. 2.8 Web Resources
  11. 3 Introduction to Visual Basic Programming
    1. 3.1 Introduction
    2. 3.2 Programmatically Displaying Text in a Label
    3. 3.3 Addition Program
    4. 3.4 Building the Addition Program
    5. 3.5 Memory Concepts
    6. 3.6 Arithmetic
    7. 3.7 Decision Making: Equality and Relational Operators
    8. 3.8 Wrap-Up
  12. 4 Introduction to Problem Solving and Control Statements
    1. 4.1 Introduction
    2. 4.2 Algorithms
    3. 4.3 Pseudocode Algorithm
    4. 4.4 Control Structures
    5. 4.5 If...Then Selection Statement
    6. 4.6 If...Then...Else Selection Statement
    7. 4.7 Nested If...Then...Else Selection Statements
    8. 4.8 Repetition Statements
    9. 4.9 Compound Assignment Operators
    10. 4.10 Formulating Algorithms: Counter-Controlled Repetition
    11. 4.11 Formulating Algorithms: Nested Control Statements
    12. 4.12 Using the Debugger: Locating a Logic Error
    13. 4.13 Wrap-Up
  13. 5 Problem Solving and Control Statements: Part 2
    1. 5.1 Introduction
    2. 5.2 For...Next Repetition Statement
    3. 5.3 Examples Using the For...Next Statement
    4. 5.4 App: Interest Calculator
    5. 5.5 Formulating Algorithms: Nested Repetition Statements
    6. 5.6 Select...Case Multiple-Selection Statement
    7. 5.7 Do...Loop While and Do...Loop Until Repetition Statements
    8. 5.8 Using Exit to Terminate Repetition Statements
    9. 5.9 Using Continue in Repetition Statements
    10. 5.10 Logical Operators
    11. 5.11 App: Dental Payment Calculator
    12. 5.12 Wrap-Up
  14. 6 Methods
    1. 6.1 Introduction
    2. 6.2 Classes and Methods
    3. 6.3 Subroutines: Methods That Do Not Return a Value
    4. 6.4 Functions: Methods That Return a Value
    5. 6.5 Implicit Argument Conversions
    6. 6.6 Option Strict and Data-Type Conversions
    7. 6.7 Passing Arguments: Pass-by-Value vs. Pass-by-Reference
    8. 6.8 Scope of Declarations
    9. 6.9 Case Study: Random-Number Generation
    10. 6.10 Case Study: A Game of Chance
    11. 6.11 Method Overloading
    12. 6.12 Optional Parameters
    13. 6.13 Using the Debugger: Debugging Commands
    14. 6.14 Wrap-Up
  15. 7 Arrays
    1. 7.1 Introduction
    2. 7.2 Arrays
    3. 7.3 Declaring and Allocating Arrays
    4. 7.4 Initializing the Values in an Array
    5. 7.5 Summing the Elements of an Array
    6. 7.6 Using Arrays to Analyze Survey Results
    7. 7.7 Die-Rolling App with an Array of Counters
    8. 7.8 Case Study: Flag Quiz
    9. 7.9 Passing an Array to a Method
    10. 7.10 For Each...Next Repetition Statement
    11. 7.11 Sorting an Array with Method Sort of Class Array
    12. 7.12 Searching an Array with Linear Search
    13. 7.13 Searching a Sorted Array with Array Method BinarySearch
    14. 7.14 Rectangular Arrays
    15. 7.15 Case Study: Maintaining Grades Using a Rectangular Array
    16. 7.16 Resizing an Array with the ReDim Statement
    17. 7.17 Wrap-Up
  16. 8 Files
    1. 8.1 Introduction
    2. 8.2 Data Hierarchy
    3. 8.3 Files and Streams
    4. 8.4 Test-Driving the Credit Inquiry App
    5. 8.5 Writing Data Sequentially to a Text File
    6. 8.6 Building Menus with the Windows Forms Designer
    7. 8.7 Credit Inquiry App: Reading Data Sequentially from a Text File
    8. 8.8 Wrap-Up
  17. 9 Object-Oriented Programming: Classes and Objects
    1. 9.1 Introduction
    2. 9.2 Classes, Objects, Methods and Instance Variables
    3. 9.3 Account Class
    4. 9.4 Value Types and Reference Types
    5. 9.5 Case Study: Card Shuffling and Dealing Simulation
    6. 9.6 Case Study: Time Class
    7. 9.7 Class Scope
    8. 9.8 Object Initializers
    9. 9.9 Auto-Implemented Properties
    10. 9.10 Using Me to Access the Current Object
    11. 9.11 Garbage Collection
    12. 9.12 Shared Class Members
    13. 9.13 Const and ReadOnly Fields
    14. 9.14 Shared Methods and Class Math
    15. 9.15 Object Browser
    16. 9.16 Wrap-Up
  18. 10 Object-Oriented Programming: Inheritance and Polymorphism
    1. 10.1 Introduction
    2. 10.2 Base Classes and Derived Classes
    3. 10.3 Business Case Study: Commission Employees Class Hierarchy
    4. 10.4 Constructors in Derived Classes
    5. 10.5 Protected Members
    6. 10.6 Introduction to Polymorphism: A Polymorphic Video Game
    7. 10.7 Abstract Classes and Methods
    8. 10.8 Case Study: Payroll System Class Hierarchy Using Polymorphism
    9. 10.9 Online Case Study: Interfaces
    10. 10.10 Wrap-Up
  19. 11 Introduction to LINQ
    1. 11.1 Introduction
    2. 11.2 Querying an Array of Primitive-Type Elements Using LINQ
    3. 11.3 Querying an Array of Reference-Type Elements Using LINQ
    4. 11.4 Deferred Execution and Transforming Query Results
    5. 11.5 LINQ Resource Center
    6. 11.6 Wrap-Up
  20. 12 Databases and LINQ
    1. 12.1 Introduction
    2. 12.2 Relational Databases
    3. 12.3 A Books Database
    4. 12.4 LINQ to Entities and the ADO.NET Entity Framework
    5. 12.5 Querying a Database with LINQ
    6. 12.6 Dynamically Binding Query Results
    7. 12.7 Retrieving Data from Multiple Tables with LINQ
    8. 12.8 Creating a Master/Detail View App
    9. 12.9 Address Book Case Study
    10. 12.10 Tools and Web Resources
    11. 12.11 Wrap-Up
  21. 13 Web App Development with ASP.NET
    1. 13.1 Introduction
    2. 13.2 Web Basics
    3. 13.3 Multitier App Architecture
    4. 13.4 Your First Web App
    5. 13.5 Standard Web Controls: Designing a Form
    6. 13.6 Validation Controls
    7. 13.7 Session Tracking
    8. 13.8 Case Study: Database-Driven ASP.NET Guestbook
    9. 13.9 Online Case Study: ASP.NET AJAX
    10. 13.10 Online Case Study: Password-Protected Books Database App
    11. 13.11 Wrap-Up
  22. 14 Windows Forms GUI: A Deeper Look
    1. 14.1 Introduction
    2. 14.2 Controls and Components
    3. 14.3 Creating Event Handlers
    4. 14.4 Control Properties and Layout
    5. 14.5 GroupBoxes and Panels
    6. 14.6 ToolTips
    7. 14.7 Mouse-Event Handling
    8. 14.8 Keyboard-Event Handling
    9. 14.9 Menus
    10. 14.10 MonthCalendar Control
    11. 14.11 DateTimePicker Control
    12. 14.12 LinkLabel Control
    13. 14.13 ListBox and CheckedListBox Controls
    14. 14.14 Multiple Document Interface (MDI) Windows
    15. 14.15 Visual Inheritance
    16. 14.16 Animation with the Timer Component
    17. 14.17 Wrap-Up
  23. 15 Graphics and Multimedia
    1. 15.1 Introduction
    2. 15.2 Drawing Classes and the Coordinate System
    3. 15.3 Graphics Contexts and Graphics Objects
    4. 15.4 Colors
    5. 15.5 Fonts
    6. 15.6 Drawing Lines, Rectangles and Ovals
    7. 15.7 Drawing Arcs
    8. 15.8 Drawing Polygons and Polylines
    9. 15.9 Additional Brush Types
    10. 15.10 Loading, Displaying and Scaling Images
    11. 15.11 Windows Media Player
    12. 15.12 Printing
    13. 15.13 Wrap-Up
  24. 16. Exception Handling: A Deeper Look
    1. 16.1 Introduction
    2. 16.2 Example: Dividing by Zero Without Exception Handling
    3. 16.3 Example: Handling DivideByZeroExceptions and FormatExceptions
    4. 16.4 .NET Exception Hierarchy
    5. 16.5 Finally Block
    6. 16.6 Exception Properties
    7. 16.7 User-Defined Exception Classes
    8. 16.8 Wrap-Up
  25. 17. Strings and Characters: A Deeper Look
    1. 17.1 Introduction
    2. 17.2 Fundamentals of Characters and Strings
    3. 17.3 String Constructors
    4. 17.4 String Indexer, Length Property and CopyTo Method
    5. 17.5 Comparing Strings
    6. 17.6 Locating Characters and Substrings in Strings
    7. 17.7 Extracting Substrings from Strings
    8. 17.8 Concatenating Strings
    9. 17.9 Miscellaneous String Methods
    10. 17.10 Class StringBuilder
    11. 17.11 Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder
    12. 17.12 Append and AppendFormat Methods of Class StringBuilder
    13. 17.13 Insert, Remove and Replace Methods of Class StringBuilder
    14. 17.14 Char Methods
    15. 17.15 Introduction to Regular Expression Processing
    16. 17.16 Wrap-Up
  26. 18. Files and Streams: A Deeper Look
    1. 18.1 Introduction
    2. 18.2 Data Hierarchy
    3. 18.3 Files and Streams
    4. 18.4 Classes File and Directory
    5. 18.5 Creating a Sequential-Access Text File
    6. 18.6 Reading Data from a Sequential-Access Text File
    7. 18.7 Case Study: A Credit-Inquiry Program
    8. 18.8 Serialization
    9. 18.9 Creating a Sequential-Access File Using Object Serialization
    10. 18.10 Reading and Deserializing Data from a Serialized Sequential-Access File
    11. 18.11 Wrap-Up
  27. 19. XML and LINQ to XML
    1. 19.1 Introduction
    2. 19.2 XML Basics
    3. 19.3 Structuring Data
    4. 19.4 XML Namespaces
    5. 19.5 Document Type Definitions (DTDs)
    6. 19.6 W3C XML Schema Documents
    7. 19.7 Extensible Stylesheet Language and XSL Transformations
    8. 19.8 LINQ to XML: Document Object Model (DOM)
    9. 19.9 LINQ to XML: XML Axis Properties
    10. 19.10 LINQ to XML: XML Literals and Embedded Expressions
    11. 19.11 XSLT with Class XslCompiledTransform
    12. 19.12 Wrap-Up
  28. 20. Windows 8 UI and XAML
    1. 20.1 Introduction
    2. 20.2 Welcome App: Introduction to XAML Declarative GUI Programming
    3. 20.3 Painter App: Layouts; Event Handling
    4. 20.4 CoverViewer App: Data Binding, Data Templates and Styles
    5. 20.5 App Lifecycle
    6. 20.6 Wrap-Up
  29. 21. Windows 8 Graphics and Multimedia
    1. 21.1 Introduction
    2. 21.2 Basic Shapes
    3. 21.3 Polylines and Polygons
    4. 21.4 SolidColorBrushes and ImageBrushes
    5. 21.5 GradientBrushes
    6. 21.6 Transforms
    7. 21.7 Windows 8 Customization: A Television GUI
    8. 21.8 Wrap-Up
  30. 22. Building a Windows Phone 8 App
    1. 22.1 Introduction
    2. 22.2 Downloading the Windows Phone 8 SDK
    3. 22.3 Tip Calculator App Introduction
    4. 22.4 Test-Driving the Tip Calculator App
    5. 22.5 Tip Calculator Technologies Overview
    6. 22.6 Building the App’s GUI
    7. 22.7 Adding Functionality to the App with Visual Basic
    8. 22.9 Windows Phone Dev Center
    9. 22.10 Selling Your Apps in the Windows Phone Marketplace
    10. 22.11 Other Popular Mobile App Platforms
    11. 22.12 Developer Documentation
    12. 22.13 Additional Windows Phone 8 Resources
    13. 22.14 Wrap-Up
  31. 23. Asynchronous Programming with Async and Await
    1. 23.1 Introduction
    2. 23.2 Basics of Async and Await
    3. 23.3 Executing an Asynchronous Task from a GUI App
    4. 23.4 Sequential Execution of Two Compute-Intensive Tasks
    5. 23.5 Asynchronous Execution of Two ComputeIntensive Tasks
    6. 23.6 Invoking a Flickr Web Service Asynchronously with WebClient
    7. 23.7 Wrap-Up
  32. 24. Web App Development with ASP.NET: A Deeper Look
    1. 24.1 Introduction
    2. 24.2 Case Study: Password-Protected Books Database App
    3. 24.3 ASP.NET Ajax
    4. 24.4 Wrap-Up
  33. 25. Web Services
    1. 25.1 Introduction
    2. 25.2 WCF Services Basics
    3. 25.3 HTTP get and post Requests
    4. 25.4 Representational State Transfer (REST)
    5. 25.5 JavaScript Object Notation (JSON)
    6. 25.6 Publishing and Consuming REST-Based XML Web Services
    7. 25.7 Publishing and Consuming REST-Based JSON Web Services
    8. 25.8 Equation Generator: Returning User-Defined Types
    9. 25.9 Wrap-Up
  34. 26. Building a Windows Azure™ Cloud Computing App
    1. 26.1 Introduction
    2. 26.2 Installing the Windows Azure SDK for Visual Studio 2012
    3. 26.3 Windows Azure Cloud Services Accounts
    4. 26.4 Favorite Twitter Searches: Introduction
    5. 26.5 Favorite Twitter Searches: Test-Drive
    6. 26.6 Favorite Twitter Searches: Technologies Overview
    7. 26.7 Favorite Twitter Searches: Code
    8. 26.8 Security, Privacy and Reliability
    9. 26.9 Microsoft Windows Azure Resources
    10. 26.10 Microsoft Windows Azure Code Samples
    11. 26.11 Additional Web Resources
    12. 26.12 Wrap-Up
  35. 27. Windows Presentation Foundation GUI
    1. 27.1 Introduction
    2. 27.2 Windows Presentation Foundation
    3. 27.3 Declarative GUI Programming Using XAML
    4. 27.4 Creating a WPF App
    5. 27.5 Laying Out Controls
    6. 27.6 Event Handling
    7. 27.7 Commands and Common Application Tasks
    8. 27.8 WPF GUI Customization
    9. 27.9 Using Styles to Change the Appearance of Controls
    10. 27.10 Customizing Windows
    11. 27.11 Defining a Control’s Appearance with Control Templates
    12. 27.12 Data-Driven GUIs with Data Binding
    13. 27.13 Wrap-Up
  36. 28. WPF Graphics and Multimedia
    1. 28.1 Introduction
    2. 28.2 Controlling Fonts
    3. 28.3 Basic Shapes
    4. 28.4 Polygons and Polylines
    5. 28.5 Brushes
    6. 28.6 Transforms
    7. 28.7 WPF Customization: A Television GUI
    8. 28.8 Animations
    9. 28.9 Speech Synthesis and Speech Recognition
    10. 28.10 Wrap-Up
  37. 29. Data Structures and Generic Collections
    1. 29.1 Introduction to Data Structures
    2. 29.2 Generic Collections Overview
    3. 29.3 Generic Classes and Methods
    4. 29.4 Wrap-Up
  38. 30. ATM Case Study, Part 1: Object-Oriented Design with the UML
    1. 30.1 Introduction
    2. 30.2 Examining the ATM Requirements Document
    3. 30.3 Identifying the Classes in a Requirements Document
    4. 30.4 Identifying Class Attributes
    5. 30.5 Identifying Objects’ States and Activities in the ATM System
    6. 30.6 Identifying Class Operations
    7. 30.7 Indicating Collaboration Among Objects
    8. 30.8 Wrap-Up
  39. 31. ATM Case Study, Part 2: Implementing an ObjectOriented Design
    1. 31.1 Introduction
    2. 31.2 Starting to Program the Classes of the ATM System
    3. 31.3 Incorporating Inheritance and Polymorphism into the ATM System
    4. 31.4 ATM Case Study Implementation
    5. 31.5 Wrap-Up
  40. A Operator Precedence Chart
  41. B Primitive Types
  42. C Number Systems
    1. C.1 Introduction
    2. C.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
    3. C.3 Converting Octal and Hexadecimal Numbers to Binary Numbers
    4. C.4 Converting from Binary, Octal or Hexadecimal to Decimal
    5. C.5 Converting from Decimal to Binary, Octal or Hexadecimal
    6. C.6 Negative Binary Numbers: Two’s-Complement Notation
  43. D ASCII Character Set
  44. E Unicode®
    1. E.1 Introduction
    2. E.2 Unicode Transformation Formats
    3. E.3 Characters and Glyphs
    4. E.4 Advantages/Disadvantages of Unicode
    5. E.5 Using Unicode
    6. E.6 Character Ranges
  45. F Creating Console Applications
    1. F.1 Introduction
    2. F.2 A Simple Console Application
    3. F.3 Creating a Console Application
  46. Index

Product information

  • Title: Visual Basic® 2012 How to Program, Sixth Edition
  • Author(s): Paul Deitel, Abbey Deitel
  • Release date: May 2013
  • Publisher(s): Pearson
  • ISBN: 9780133407099