Programming Visual Basic 2008

Book description

Ever since Visual Basic was merged into .NET, it's become the core language for creating business applications with Windows. The latest version, VB 2008, is even more useful -- and provides even more incentive for migrating from VB 6. All it lacks is a good book on how to harness its power. Programming Visual Basic 2008 fills the void.

Written in a lively and engaging style by a developer who's grown up with Visual Basic, including both VB 6 and VB .NET, this hands-on guide addresses the core topics of the new VB, from basic to complex, with plenty of code examples.

Programming Visual Basic 2008 also examines .NET programming from the application level with a chapter-by-chapter plan for developing, documenting, and deploying a full data-driven application. You learn, step-by-step, how to build and deploy a library management system, complete with patron, inventory, and barcode support.

The book's broad range of topics include:

  • VB language and its syntax
  • An overview of the .NET Framework
  • Object-oriented development in VB and .NET
  • Generic objects, collections, and nullable types
  • Design and management of software projects
  • Integrating desktop features with Windows Forms
  • Database design with SQL Server 2008
  • Database interface design with ADO.NET
  • The new LINQ feature, and how to use it within VB and .NET
  • Embedding XML within application source code
  • Encryption and authentication in .NET
  • Interacting with data stored in files and directories
  • Web development using ASP.NET
  • Deploying an application to a user's workstation
  • And much more

Programming Visual Basic 2008 is ideal for VB 6 programmers who are ready to move to .NET, as well as VB.NET programmers who wish to improve their project-focused software development skills. Programming novices and developers coming from other languages will find the book valuable because of its language instruction and project design knowledge.

Once you finish the book, you will have a firm grasp of VB 2008's core concepts and language elements, and understand how to build VB projects as they were intended -- as complete, cohesive solutions.

Publisher resources

View/Submit Errata

Table of contents

  1. Programming Visual Basic 2008
  2. Dedication
  3. A Note Regarding Supplemental Files
  4. Preface
    1. Who Is Reading This Book?
    2. What’s in This Book?
    3. What’s in the Software Download?
    4. Conventions Used in This Book
    5. Using Code Examples
    6. How to Contact Us
    7. Safari® Books Online
    8. Acknowledgments
  5. 1. Introducing .NET
    1. Before .NET
    2. Back to Introducing .NET
    3. The .NET Object
      1. Objects and Data
      2. Objects and Interfaces
      3. Objects and Instances
    4. The Parts of the .NET Framework
      1. The Common Language Runtime
      2. The Common Language Specification
      3. The Common Type System
      4. .NET Class Libraries
      5. Assemblies and Manifests
      6. Metadata and Attributes
      7. Versioning
    5. From Source Code to EXE
    6. What About Visual Studio and Visual Basic?
    7. Visual Studio 2008
    8. Summary
    9. Project
  6. 2. Introducing Visual Basic
    1. The History of the Visual Basic Revolution
    2. Visual Basic from the Inside Out
    3. The Basics of Logic and Data
    4. Data Types and Variables
      1. Literals
      2. Variables
      3. Value Types and Reference Types
      4. Data Types
      5. Advanced Declaration
      6. Constants
      7. Local Declaration and Fields
    5. Intermission
    6. Comments
    7. Option Statements
    8. Basic Operators
    9. Using Functions and Subroutines
    10. Conditions
      1. If Statements
      2. Select Case Statements
      3. IIf and If Functions
    11. Loops
      1. For . . . Next Loops
      2. For Each . . . Next Loops
      3. Do . . . Loop Loops
      4. Exit Statements
      5. Continue Statements
    12. Creating Your Own Procedures
      1. Subroutines
      2. Functions
      3. Properties
      4. Where to Put Your Procedures
    13. Other Flow Control Features
      1. The GoTo Statement
      2. The Return Statement
      3. The End and Stop Statements
    14. Events and Event Handlers
    15. Namespaces
      1. Referencing Namespaces
      2. Namespaces in Your Project
    16. The My Namespace
    17. Summary
    18. Project
  7. 3. Introducing the Project
    1. The Library Project
      1. Library Item Features
      2. Patron Features
      3. Administrative Features
      4. The Application As a Whole
    2. The Needs of the Users
      1. Data and Information
      2. Process
      3. Usability
      4. Commonality
      5. Project-Specific Needs
    3. The Life of a Project
      1. Project Kickoff
      2. Documentation
      3. Project Goals
      4. Design and Planning
      5. Project Approval
      6. Software and Other Development
      7. Changes to the Project
      8. Acceptance Criteria Testing
      9. Project Acceptance
      10. Deployment and Distribution
      11. Ongoing Support
    4. Summary
    5. Project
  8. 4. Designing the Database
    1. Relational Databases
    2. SQL Server 2005
    3. SQL
      1. DDL Statements
      2. DML Statements
      3. Beyond Basic SQL
    4. Using Databases in Visual Basic
    5. Documenting the Database
    6. Summary
    7. Project
      1. Technical Resource Kit Content
        1. Security-related tables
          1. Activity
          2. GroupName
          3. GroupActivity
          4. UserName
        2. Support code tables
          1. CodeAuthorType
          2. CodeCopyStatus
          3. CodeLocation
          4. CodeMediaType
          5. CodePatronGroup
          6. CodeSeries
        3. Library items
          1. NamedItem
          2. ItemCopy
          3. Publisher
          4. Author
          5. ItemAuthor
          6. Keyword
          7. ItemKeyword
          8. Subject
          9. ItemSubject
        4. Patron-related tables
          1. Patron
          2. PatronCopy
          3. PatronPayment
        5. Bar code-related tables
          1. BarcodeSheet
          2. BarcodeLabel
          3. BarcodeLabelItem
        6. Other miscellaneous tables
          1. Holiday
          2. SystemValue
      2. Creating the Database
  9. 5. .NET Assemblies
    1. What Is an Assembly?
    2. What’s Inside an Assembly?
      1. Reflection
    3. Assemblies and Applications
    4. The My Namespace and Assemblies
    5. Directives and Assemblies
    6. Summary
    7. Project
      1. Adding Controls
      2. Adding the Code to the Form
      3. Setting the Version Number
      4. Adding the Main Form
      5. Extra Credit: Adding an Icon
      6. Save Your Work
  10. 6. Data and Data Types
    1. The Nature of Computer Data
    2. Data in .NET
      1. Integer Data Types
      2. Decimal Data Types
      3. Character Data Types
      4. Date and Time Data Type
      5. Boolean Data Type
      6. The System.Object Class
      7. Value Types and Reference Types
    3. Visual Basic Data Types
    4. Literals
    5. Constants
    6. Enumerations
    7. Variables
      1. Scope and Lifetime
    8. Variable and Constant Naming Conventions
    9. Local Type Inference
    10. Operators
    11. Static Variables
    12. Arrays
      1. Multidimensional Arrays
      2. Array Boundaries
      3. Initializing Arrays
    13. Nullable Types
    14. Common Visual Basic Functions
      1. Conversion Functions
      2. Date-Related Functions
      3. Numeric Functions
      4. String Functions
      5. Other Functions
    15. Summary
    16. Project
  11. 7. Windows Forms
    1. Inside a Windows Application
      1. Everything Is a Window
      2. Messages and the Message Pump
      3. Window Procedures
    2. Windows in .NET
      1. Forms and Controls
      2. Designing Windows Forms Applications
      3. Working with Forms
      4. Adding Controls
      5. Events and Delegates
    3. Making Forms Useful
    4. Summary
    5. Project
      1. Configuring the Splash Screen
      2. Configuring the Main Form
      3. Making the Program Single-Instance
  12. 8. Classes and Inheritance
    1. Object-Oriented Programming Concepts
      1. The Object
      2. Abstraction
      3. Encapsulation
      4. Inheritance
      5. Polymorphism
      6. Interfaces and Implementation
    2. OOP in Visual Basic and .NET
      1. Classes
      2. Class Members
      3. Shared Class Members
      4. Overloaded Members and Optional Arguments
      5. Inheritance
      6. Creating Instances of Classes
      7. Constructors and Destructors
      8. Interfaces
      9. Modules and Structures
      10. Partial Methods
    3. Related Issues
      1. The MsgBox Method
      2. Using DoEvents
      3. ParamArray Arguments
    4. Summary
    5. Project
      1. Supporting List and Combo Boxes
      2. Editing Code Tables
      3. The Generic Detail Form
      4. The Generic Summary Form
  13. 9. Functional Programming
    1. Lambda Expressions
      1. Implying Lambdas
      2. Expression Trees
      3. Complex Lambdas
      4. Variable Lifting
    2. Object Initializers
    3. Error Handling in Visual Basic
    4. The Nature of Errors in Visual Basic
    5. Unstructured Error Handling
      1. Disabling Error Handling
      2. Ignoring Errors
    6. Structured Error Handling
      1. The Try Clause
      2. The Catch Clause
      3. The Finally Clause
    7. Unhandled Errors
    8. Managing Errors
      1. Generating Errors
      2. Mixing Error-Handling Methods
      3. The System.Exception Class
      4. The Err Object
      5. The Debug Object
      6. Other Visual Basic Error Features
    9. Summary
    10. Project
      1. General Error Handler
      2. Unhandled Error Capture
  14. 10. ADO.NET
    1. What Is ADO.NET?
    2. Overview of ADO.NET
      1. Providers
      2. Data Sets
    3. Data Sets Versus No Data Sets
      1. MARS Support
    4. Connecting to SQL Server with Visual Studio
      1. Creating a Data Source
      2. Using a Data Source
      3. Data Binding
    5. Interacting with SQL Server in Code
      1. Building the Connection String
      2. Establishing the Connection
      3. Using SQL Statements
      4. Processing the Results
      5. Modifying Data
    6. Database Transactions
    7. ADO.NET Entity Framework
    8. Summary
    9. Project
      1. Reference the Data Namespaces
      2. Connecting to the Database
      3. Interacting with the Database
      4. Processing Data Values
      5. System-Level Configuration
  15. 11. Security
    1. Security Features in .NET
    2. Cryptography and Encryption
      1. Keeping Secrets
      2. Data Stability
      3. Identity Verification
    3. Encryption in .NET
      1. Symmetric Cryptography
      2. Asymmetric Cryptography
      3. Hashing
    4. Other Security Features
      1. User Authentication and My.User
      2. The SecureString Class
    5. Summary
    6. Project
      1. Authentication Support
      2. Encrypting Passwords
      3. Undoing Some Previous Changes
      4. Managing Security Groups
      5. Managing Users
      6. Per-User Experience
  16. 12. Overloads and Extensions
    1. What Is Operator Overloading?
    2. What Can You Overload?
      1. Mathematical Operators
      2. Comparison Operators
      3. Bitwise and Logical Operators
      4. The CType Operator
    3. Other Operator Overloading Issues
      1. Declaration Requirements
      2. Overloading Overloads
      3. Be Nice
    4. Extension Methods
    5. Summary
    6. Project
      1. Overloading a Conversion
      2. Global Support Features
      3. Extending a Framework-Supplied Class
      4. Record Editors and Supporting Forms
        1. Search-limiting forms
        2. Keyword and subject editors
        3. More named item support forms
        4. Inherited code editors
      5. Connecting the Editors to the Main Form
      6. Setting the Default Location
  17. 13. XML
    1. What Is XML?
    2. The XML Rule
    3. XML Content
      1. Some Basic XML
      2. Some Basic—and Meaningful—XML
      3. What About the Human-Readable Part?
      4. XML Schemas
      5. XML Namespaces
    4. Using XML in .NET: The Old Way
      1. The Basic XML Classes, Basically
      2. Finding Needles and Haystacks
      3. Schema Verification
      4. XML Transformations
    5. Using XML in .NET: The New Way
      1. Embedded XML Expressions
      2. XML Axis Properties
      3. Namespaces and Schemas for XML Literals
    6. Summary
    7. Project
      1. Update Technical Documentation
        1. Report Configuration File
      2. Create Report Entry Class
      3. Design the Report Form
      4. Populate Reports from Configuration File
      5. Running the Reports
      6. Connecting the Select Report Form
  18. 14. Application Settings
    1. A Short History of Settings
    2. Settings in Visual Basic 2008
      1. Adding Settings to a Project
      2. My.Settings
      3. Bound Settings
    3. Summary
    4. Project
      1. Update Technical Documentation
        1. User settings
      2. Add the Settings
      3. Positioning the Main Form
      4. Caching and Using Settings
      5. Adding Configuration Forms
      6. Connecting to the Configured Database
  19. 15. Files and Directories
    1. Traditional Visual Basic File Management
    2. Manipulating Files Through Streams
      1. Stream Features
      2. Using a Stream
      3. Beyond Stream Bytes
      4. Reading a File Via a Stream
    3. File Management with the My Namespace
      1. My Namespace Versus Visual Basic Commands
      2. Reading and Writing Files Through My
    4. Summary
    5. Project
      1. Configuring Log Output
      2. Other Log Output Options
      3. Obtaining a Bar Code Font
  20. 16. Generics
    1. What Are Generics?
    2. Variations of Generic Declaration
      1. Multiple Placeholders
      2. Data Type and Interface Constraints
      3. Simultaneous Constraints
      4. Nesting Generic Types
      5. Non-Generic Types with Generic Members
      6. Overloading Generic Types and Members
      7. Generics and Collections
      8. Generic Nullable Types
    3. Summary
    4. Project
      1. Managing Holidays
  21. 17. LINQ
    1. What Is LINQ?
      1. The Good
      2. The Bad
      3. Supporting Technologies
    2. Anonymous Types
    3. LINQ to Objects
    4. Basic Query Expressions
      1. The From Clause
      2. The Select Clause
      3. The Distinct Clause
      4. The Where Clause
      5. The Order By Clause
      6. Joining Sources
      7. Skip and Take
    5. Converting Results to Other Forms
    6. Aggregate Queries
    7. Advanced Query Expressions
    8. LINQ to XML
    9. LINQ for ADO.NET-Related Data
      1. LINQ to Entities
      2. LINQ to DataSet
      3. LINQ to SQL
    10. Deferred Execution
    11. Summary
    12. Project
      1. Looking Up Library Items
      2. Maintaining Search History
      3. Showing Item Detail
      4. Enabling the Search Features
  22. 18. User Interface
    1. Overview of GDI+
    2. Selecting a Canvas
      1. Obtaining and Creating Graphics Objects
      2. Disposing of Graphics Objects Properly
    3. Choosing Pens and Brushes
      1. Pens
      2. Brushes
    4. Flowing Text from the Font
    5. Imagining Images
    6. Exposing Your True Artist
    7. Paths: Drawings on Macro-Vision
    8. Keeping It Regional
    9. Twisting and Turning with Transformations
    10. Enhancing Controls Through Owner Draw
    11. Windows Presentation Foundation
      1. WPF and XAML
    12. Enhancing Classes with Attributes
    13. Summary
    14. Project
      1. Install the Bar Code Font
      2. Using Owner Draw
      3. Bar Code Design
      4. Fun with Graphics
  23. 19. Localization and Globalization
    1. Defining Globalization and Localization
    2. Resource Files
    3. The My.Resources Object
    4. Localizing Forms Within Visual Studio
    5. Adding Resources Outside Visual Studio
    6. Manually Compiling Resources
      1. Resource File Generation
      2. Compiling Satellite Assemblies
    7. Other Localization Features
    8. Summary
    9. Project
      1. Tracking Patron Payments
      2. Calculating Patron Fines
      3. Patron Record Access
      4. Patron Password Modification
      5. Collecting Patron Payments
      6. Managing All Fines and Payments
      7. Connecting Patron Features to the Main Form
      8. Dueling Patron Management Forms
  24. 20. Printing
    1. Printing in Windows
    2. Printing in .NET
    3. Printing a Document
    4. Print Preview
    5. Counting and Numbering Pages
    6. Printing in “Raw” Mode
    7. Summary
    8. Project
      1. Supporting Raw Printing
      2. Printing Tickets
      3. Printing Bar Codes
      4. Renewal of Checked-Out Patron Items
      5. Support for Check-In and Checkout
      6. Checking Out Items
      7. Checking In Items
  25. 21. Reporting
    1. Report Options in .NET
      1. PrintDocument-Based Printing
      2. HTML/Web Pages
      3. XPS Documents
      4. Reporting Services and Controls
      5. Crystal Reports
      6. Integration with Microsoft Office
    2. Using Reporting Controls in .NET
      1. Adding the Data Source
      2. Adding a Report Design Surface
      3. Designing the Report Surface
      4. Using a Report Control
      5. Running the Report
      6. Adding a Page Header and Footer
      7. Support for Grouping and Sorting
      8. Enhanced Style Formatting
      9. Using Custom Data
      10. Supplying Custom Data Sources
    3. Summary
    4. Project
      1. Crafting the SQL Statements
      2. Adding Report Schemas
      3. Adding Reports
      4. Adding a Report Viewer
      5. Adding Built-in Reports
  26. 22. Licensing Your Application
    1. Software Licensing Options
      1. License Agreement Only
      2. Generated General License Key
      3. Generated Custom License Key
      4. License Key with Hardware Identity or Lock
      5. Controlled Access
    2. License Agreements
    3. Obfuscation
    4. The Library Licensing System
      1. Designing the License File
      2. Generating the License File
      3. Installing the License File
      4. Using the License File
    5. Summary
    6. Project
      1. Update Technical Documentation
        1. License File
      2. Library License Helper Application
      3. Adding the License to the Library Program
      4. Display the License on the About Form
      5. Enforcing the License
      6. Daily Item Processing
  27. 23. Web Development
    1. How the Internet Works
    2. Programming the Internet
    3. ASP.NET Features
    4. Trying Out ASP.NET
    5. More About Events
    6. State and View State
    7. Data Validation
    8. Database Integration
    9. Windows Communication Foundation
    10. Summary
    11. Project
      1. Configuring the Database
      2. The Default Page
      3. Search Results
      4. Search Detail
      5. Statistics Report
  28. 24. Adding Online Help
    1. Windows Online Help Options
      1. WinHelp
      2. HTML Help
      3. Microsoft Help 2
      4. Assistance Platform
      5. Other Methods
    2. Designing HTML Help
      1. Content Files
      2. Help Project File
      3. Help Contents File
      4. Help Keywords (Index) File
      5. Formatting Help Windows
    3. Accessing HTML Help
      1. HelpProvider Control
        1. Accessing HTML help files
        2. Showing pop-up help
      2. ShowHelp Method
    4. Summary
    5. Project
      1. Building the Help Files
      2. Adding Help Support to the Application
  29. 25. Deployment
    1. What’s Involved in Deployment?
    2. Deployment Methods Within Visual Studio
      1. Direct ASP.NET Deployment
      2. XCopy Deployment
      3. Windows Installer Deployment
        1. Step 1
        2. Step 2
        3. Step 3
        4. Step 4
        5. Step 5
        6. After the wizard
        7. Generating the MSI file
      4. ClickOnce Deployment
    3. Summary
    4. Project
      1. Planning the Deployment
      2. Building the Setup Project
      3. The Distribution Media
  30. 26. Project Complete
    1. The Library Project
    2. Visual Basic Flexibility
    3. The Programming Mindset
    4. Summary
  31. A. Installing the Software
    1. Download the Software
    2. Install the Software
    3. Install Project Templates
    4. Install Code Snippets
    5. Bar Code Support
  32. B. Software License Agreement
    1. Terms of Use
  33. Index
  34. About the Author
  35. Colophon
  36. Copyright

Product information

  • Title: Programming Visual Basic 2008
  • Author(s): Tim Patrick
  • Release date: May 2008
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596555184