Microsoft® Visual Basic® 2010 Step by Step

Book description

Your hands-on, step-by-step guide to learning Visual Basic 2010.

Teach yourself the essential tools and techniques for Visual Basic 2010-one step at a time. No matter what your skill level, you'll find the practical guidance and examples you need to start building professional applications for Windows and the Web.

Discover how to:

  • Work in the Microsoft Visual Studio 2010 Integrated Development Environment (IDE)

  • Master essential techniques-from managing data and variables to using inheritance and dialog boxes

  • Create professional-looking Uis; add visual effects and print support

  • Build compelling Web features with the Visual Web Developer tool

  • Use Microsoft ADO.NET and advanced data presentation controls

  • Debug your programs and handle run-time errors

  • Use new features, such as Query Builder, and Microsoft .NET Framework



  • For customers who purchase an ebook version of this title, instructions for downloading the CD files can be found in the ebook.

    Table of contents

    1. Dedication
    2. Acknowledgments
    3. Introduction
      1. Visual Basic Versions
        1. Downloading Visual Basic 2010 Express
      2. Finding Your Best Starting Point in This Book
      3. Hardware and Software Requirements
      4. Prerelease Software
      5. Installing and Using the Practice Files
        1. Installing the Practice Files
        2. Using the Practice Files
      6. Uninstalling the Practice Files
      7. Conventions and Features in This Book
        1. Conventions
        2. Other Features
      8. Helpful Support Links
        1. Visual Studio 2010 Software Support
      9. Support for This Book
        1. We Want to Hear from You
    4. I. Getting Started with Microsoft Visual Basic 2010
      1. 1. Exploring the Visual Studio Integrated Development Environment
        1. The Visual Studio Development Environment
        2. The Visual Studio Tools
          1. The Designer
          2. Running a Visual Basic Program
        3. The Properties Window
        4. Moving and Resizing the Programming Tools
          1. Moving and Resizing Tool Windows
          2. Docking Tool Windows
          3. Hiding Tool Windows
        5. Switching Among Open Files and Tools by Using the IDE Navigator
        6. Opening a Web Browser Within Visual Studio
        7. Getting Help
          1. Managing Help Settings
          2. Using F1 Help
            1. Inside MSDN Help
        8. Customizing IDE Settings to Match Step-by-Step Exercises
          1. Setting the IDE for Visual Basic Development
          2. Checking Project and Compiler Settings
        9. One Step Further: Exiting Visual Studio
        10. Chapter 1 Quick Reference
      2. 2. Writing Your First Program
        1. Lucky Seven: Your First Visual Basic Program
        2. Programming Steps
        3. Creating the User Interface
        4. Setting the Properties
        5. The Picture Box Properties
        6. Writing the Code
        7. A Look at the Button1_Click Procedure
        8. Running Visual Basic Applications
        9. Sample Projects on Disk
        10. Building an Executable File
        11. Deploying Your Application
        12. One Step Further: Adding to a Program
        13. Chapter 2 Quick Reference
      3. 3. Working with Toolbox Controls
        1. The Basic Use of Controls: The Hello World Program
        2. Using the DateTimePicker Control
          1. The Birthday Program
        3. Controls for Gathering Input
          1. Using Group Boxes and Radio Buttons
          2. Processing Input with List Boxes
          3. A Word About Terminology
        4. One Step Further: Using the LinkLabel Control
        5. Chapter 3 Quick Reference
      4. 4. Working with Menus, Toolbars, and Dialog Boxes
        1. Adding Menus by Using the MenuStrip Control
        2. Adding Access Keys to Menu Commands
        3. Processing Menu Choices
        4. Adding Toolbars with the ToolStrip Control
        5. Using Dialog Box Controls
        6. Event Procedures That Manage Common Dialog Boxes
        7. One Step Further: Assigning Shortcut Keys to Menus
        8. Chapter 4 Quick Reference
    5. II. Programming Fundamentals
      1. 5. Visual Basic Variables and Formulas and the .NET Framework
        1. The Anatomy of a Visual Basic Program Statement
        2. Using Variables to Store Information
          1. Setting Aside Space for Variables: The Dim Statement
          2. Implicit Variable Declaration
        3. Using Variables in a Program
        4. Using a Variable to Store Input
        5. Using a Variable for Output
        6. Working with Specific Data Types
          1. Constants: Variables That Don’t Change
        7. Working with Visual Basic Operators
          1. Basic Math: The +, –, *, and / Operators
          2. Using Advanced Operators: \, Mod, ^, and &
        8. Working with Math Methods in the .NET Framework
        9. One Step Further: Establishing Order of Precedence
          1. Using Parentheses in a Formula
        10. Chapter 5 Quick Reference
      2. 6. Using Decision Structures
        1. Event-Driven Programming
        2. Using Conditional Expressions
        3. If … Then Decision Structures
          1. Testing Several Conditions in an If … Then Decision Structure
          2. Using Logical Operators in Conditional Expressions
          3. Short-Circuiting by Using AndAlso and OrElse
        4. Select Case Decision Structures
          1. Using Comparison Operators with a Select Case Structure
        5. One Step Further: Detecting Mouse Events
        6. Chapter 6 Quick Reference
      3. 7. Using Loops and Timers
        1. Writing For … Next Loops
        2. Using a Counter Variable in a Multiline TextBox Control
        3. Creating Complex For … Next Loops
          1. Using a Counter That Has Greater Scope
        4. Writing Do Loops
        5. Avoiding an Endless Loop
        6. The Timer Control
        7. Creating a Digital Clock by Using a Timer Control
        8. Using a Timer Object to Set a Time Limit
        9. One Step Further: Inserting Code Snippets
        10. Chapter 7 Quick Reference
      4. 8. Debugging Visual Basic Programs
        1. Finding and Correcting Errors
        2. Three Types of Errors
        3. Identifying Logic Errors
        4. Debugging 101: Using Debugging Mode
        5. Tracking Variables by Using a Watch Window
        6. Visualizers: Debugging Tools That Display Data
        7. Using the Immediate and Command Windows
        8. Switching to the Command Window
        9. One Step Further: Removing Breakpoints
        10. Chapter 8 Quick Reference
      5. 9. Trapping Errors by Using Structured Error Handling
        1. Processing Errors by Using the Try … Catch Statement
          1. When to Use Error Handlers
          2. Setting the Trap: The Try … Catch Code Block
          3. Path and Disc Drive Errors
        2. Writing a Disc Drive Error Handler
        3. Using the Finally Clause to Perform Cleanup Tasks
        4. More Complex Try … Catch Error Handlers
          1. The Exception Object
          2. Specifying a Retry Period
          3. Using Nested Try … Catch Blocks
        5. Comparing Error Handlers with Defensive Programming Techniques
        6. One Step Further: The Exit Try Statement
        7. Chapter 9 Quick Reference
      6. 10. Creating Modules and Procedures
        1. Working with Modules
          1. Creating a Module
        2. Working with Public Variables
        3. Creating Procedures
        4. Writing Function Procedures
          1. Function Syntax
          2. Calling a Function Procedure
          3. Using a Function to Perform a Calculation
        5. Writing Sub Procedures
          1. Sub Procedure Syntax
          2. Calling a Sub Procedure
          3. Using a Sub Procedure to Manage Input
        6. One Step Further: Passing Arguments by Value and by Reference
        7. Chapter 10 Quick Reference
      7. 11. Using Arrays to Manage Numeric and String Data
        1. Working with Arrays of Variables
          1. Creating an Array
          2. Declaring a Fixed-Size Array
          3. Setting Aside Memory
          4. Working with Array Elements
          5. Declaring an Array and Assigning It Initial Values
          6. Creating a Fixed-Size Array to Hold Temperatures
          7. Creating a Dynamic Array
        2. Preserving Array Contents by Using ReDim Preserve
          1. Using ReDim for Three-Dimensional Arrays
        3. One Step Further: Processing Large Arrays by Using Methods in the Array Class
          1. The Array Class
        4. Chapter 11 Quick Reference
      8. 12. Working with Collections
        1. Working with Object Collections
          1. Referencing Objects in a Collection
          2. Writing For Each … Next Loops
          3. Experimenting with Objects in the Controls Collection
          4. Using the Name Property in a For Each … Next
        2. Creating Your Own Collections
          1. Declaring New Collections
        3. One Step Further: VBA Collections
          1. Entering the Word Macro
        4. Chapter 12 Quick Reference
      9. 13. Exploring Text Files and String Processing
        1. Reading Text Files
          1. The My Namespace
          2. The StreamReader Class
          3. Using the ReadAllText Method
        2. Writing Text Files
          1. The WriteAllText Method
          2. The StreamWriter Class
          3. Using the WriteAllText Method
        3. Processing Strings with the String Class
        4. Sorting Text
          1. Working with ASCII Codes
          2. Sorting Strings in a Text Box
          3. Examining the Sort Text Program Code
        5. Protecting Text with Basic Encryption
        6. One Step Further: Using the Xor Operator
          1. Examining the Encryption Program Code
        7. Chapter 13 Quick Reference
    6. III. Designing the User Interface
      1. 14. Managing Windows Forms and Controls at Run Time
        1. Adding New Forms to a Program
        2. How Forms Are Used
        3. Working with Multiple Forms
          1. Using the DialogResult Property in the Calling Form
        4. Positioning Forms on the Windows Desktop
          1. Minimizing, Maximizing, and Restoring Windows
        5. Adding Controls to a Form at Run Time
        6. Organizing Controls on a Form
        7. One Step Further: Specifying the Startup Object
        8. Chapter 14 Quick Reference
      2. 15. Adding Graphics and Animation Effects
        1. Adding Artwork by Using the System.Drawing Namespace
          1. Using a Form’s Coordinate System
          2. The System.Drawing.Graphics Class
          3. Using the Form’s Paint Event
        2. Adding Animation to Your Programs
          1. Moving Objects on the Form
          2. The Location Property
          3. Creating Animation by Using a Timer Object
        3. Expanding and Shrinking Objects While a Program is Running
        4. One Step Further: Changing Form Transparency
        5. Chapter 15 Quick Reference
      3. 16. Inheriting Forms and Creating Base Classes
        1. Inheriting a Form by Using the Inheritance Picker
        2. Creating Your Own Base Classes
          1. Adding a New Class to Your Project
        3. One Step Further: Inheriting a Base Class
        4. Chapter 16 Quick Reference
      4. 17. Working with Printers
        1. Using the PrintDocument Class
          1. Printing Text from a Text Box Object
        2. Printing Multipage Text Files
        3. One Step Further: Adding Print Preview and Page Setup Dialog Boxes
        4. Chapter 17 Quick Reference
    7. IV. Database and Web Programming
      1. 18. Getting Started with ADO .NET
        1. Database Programming with ADO.NET
          1. Database Terminology
          2. Working with an Access Database
          3. The Data Sources Window
        2. Using Bound Controls to Display Database Information
        3. One Step Further: SQL Statements, LINQ, and Filtering Data
        4. Chapter 18 Quick Reference
      2. 19. Data Presentation Using the DataGridView Control
        1. Using DataGridView to Display Database Records
        2. Formatting DataGridView Cells
        3. Adding a Second Data Grid View Object
        4. One Step Further: Updating the Original Database
        5. Chapter 19 Quick Reference
      3. 20. Creating Web Sites and Web Pages by Using Visual Web Developer and ASP.NET
        1. Inside ASP.NET
          1. Web Pages vs. Windows Forms
          2. Server Controls
          3. HTML Controls
        2. Building a Web Site by Using Visual Web Developer
          1. Considering Software Requirements for ASP.NET Programming
        3. Using the Web Page Designer
        4. Adding Server Controls to a Web Site
          1. Writing Event Procedures for Web Page Controls
        5. Customizing the Web Site Template
        6. Displaying Database Records on a Web Page
        7. One Step Further: Setting Web Site Titles in Internet Explorer
        8. Chapter 20 Quick Reference
    8. A. Where to Go for More Information
      1. Visual Basic Web Sites
      2. Video Web Sites
      3. Books about Visual Basic and Visual Studio Programming
        1. Visual Basic Programming
        2. Microsoft .NET Framework
        3. Database Programming with ADO.NET
        4. Web Programming with ASP.NET
        5. Office Programming
        6. General Books about Programming and Computer Science
    9. Index
    10. About the Author
    11. Copyright

    Product information

    • Title: Microsoft® Visual Basic® 2010 Step by Step
    • Author(s): Michael Halvorson
    • Release date: May 2010
    • Publisher(s): Microsoft Press
    • ISBN: 9780735645332