You are previewing Stephens' Visual Basic® Programming 24-Hour Trainer.
O'Reilly logo
Stephens' Visual Basic® Programming 24-Hour Trainer

Book Description

This unique book-and-video package for Stephens' Visual Basic® Programming 24-Hour Trainer

Start from scratch, and even if you don?t know a thing about Visual Basic, you soon will with this thorough introduction to Visual Basic programming. Using easy-to-follow lessons and step-by-step instruction, this practical book teaches you concepts and hands-on techniques, then reinforces your learning with video screencasts and supplemental materials. Follow the exercises, then access the Try It section on the video, and watch as well-known VB authority and author Rod Stephens works through programming problems.

  • Introduces Visual Basic programming to beginning programmers; no prior experience is necessary

  • Covers Visual Basic programming concepts and techniques, as well as the Visual Studio development environment

  • Provides a series of easy-to-follow lessons, supplemented by instructional video

  • Stephens' Visual Basic Programming 24-Hour Trainer is an exceptional book-and-video package that will have you programming in Visual Basic in no time.

    Table of Contents

    1. Copyright
    2. ABOUT THE AUTHOR
    3. ABOUT THE TECHNICAL EDITOR
    4. Credits
    5. ACKNOWLEDGMENTS
    6. INTRODUCTION
      1. WHO THIS BOOK IS FOR
      2. WHAT THIS BOOK COVERS (AND WHAT IT DOESN'T)
      3. THE WROX 24-HOUR TRAINER APPROACH
      4. HOW THIS BOOK IS STRUCTURED
        1. Section I: The Visual Studio IDE and Controls
        2. Section II: Variables and Calculations
        3. Section III: Program Statements
        4. Section IV: Classes
        5. Section V: System Interactions
        6. Section VI: Specialized Topics
        7. Appendices
      5. WHAT YOU NEED TO USE THIS BOOK
      6. CONVENTIONS
      7. SOURCE CODE
      8. ERRATA
      9. P2P.WROX.COM
      10. E-MAIL ME
    7. I. The Visual Studio IDE and Controls
      1. 1. Getting Started with the Visual Studio IDE
        1. 1.1. INSTALLING VISUAL BASIC
        2. 1.2. CONFIGURING THE IDE
        3. 1.3. BUILDING YOUR FIRST PROGRAM
        4. 1.4. COPYING PROJECTS
        5. 1.5. EXPLORING THE IDE
        6. 1.6. TRY IT
          1. 1.6.1. Lesson Requirements
          2. 1.6.2. Hints
          3. 1.6.3. Step-by-Step
        7. 1.7. EXERCISES
      2. 2. Creating Controls
        1. 2.1. UNDERSTANDING CONTROLS
          1. 2.1.1. Properties
          2. 2.1.2. Methods
          3. 2.1.3. Events
        2. 2.2. CREATING CONTROLS
        3. 2.3. SETTING CONTROL PROPERTIES
          1. 2.3.1. Control Names
          2. 2.3.2. Popular Properties
          3. 2.3.3. Modifying Properties in Code
            1. 2.3.3.1. Line Continuation
            2. 2.3.3.2. Relaxed Delegates
            3. 2.3.3.3. Other Property Types
        4. 2.4. ARRANGING CONTROLS
          1. 2.4.1. Snap Lines
          2. 2.4.2. Arrow Keys
          3. 2.4.3. The Format Menu and Layout Toolbar
        5. 2.5. TRY IT
          1. 2.5.1. Lesson Requirements
          2. 2.5.2. Hints
          3. 2.5.3. Step-by-Step
        6. 2.6. EXERCISES
      3. 3. Making Controls Arrange Themselves
        1. 3.1. RESTRICTING FORM SIZE
        2. 3.2. USING ANCHOR PROPERTIES
        3. 3.3. USING DOCK PROPERTIES
        4. 3.4. TRY IT
          1. 3.4.1. Lesson Requirements
          2. 3.4.2. Hints
          3. 3.4.3. Step-by-Step
        5. 3.5. EXERCISES
      4. 4. Handling Events
        1. 4.1. MAKING EVENT HANDLERS
        2. 4.2. USING EVENT PARAMETERS
          1. 4.2.1. Tracking Mouse Movement
          2. 4.2.2. Detecting Mouse Clicks
        3. 4.3. REMOVING EVENT HANDLERS
        4. 4.4. ADDING AND REMOVING EVENT HANDLERS IN CODE
        5. 4.5. USEFUL EVENTS
        6. 4.6. TRY IT
          1. 4.6.1. Lesson Requirements
          2. 4.6.2. Hints
          3. 4.6.3. Step-by-Step
        7. 4.7. EXERCISES
      5. 5. Making Menus
        1. 5.1. CREATING MENUS
        2. 5.2. SETTING MENU PROPERTIES
        3. 5.3. HANDLING MENU EVENTS
        4. 5.4. CREATING CONTEXT MENUS
        5. 5.5. TRY IT
          1. 5.5.1. Lesson Requirements
          2. 5.5.2. Hints
          3. 5.5.3. Step-by-Step
        6. 5.6. EXERCISES
      6. 6. Making Tool Strips and Status Strips
        1. 6.1. USING TOOL STRIPS
        2. 6.2. USING TOOL STRIP CONTAINERS
        3. 6.3. USING STATUS STRIPS
        4. 6.4. TRY IT
          1. 6.4.1. Lesson Requirements
          2. 6.4.2. Hints
          3. 6.4.3. Step-by-Step
        5. 6.5. EXERCISES
      7. 7. Using RichTextBoxes
        1. 7.1. USING RICHTEXTBOX PROPERTIES
        2. 7.2. GIVING THE USER CONTROL
        3. 7.3. USING RICHTEXTBOX METHODS
        4. 7.4. TRY IT
          1. 7.4.1. Lesson Requirements
          2. 7.4.2. Hints
          3. 7.4.3. Step-by-Step
        5. 7.5. EXERCISES
      8. 8. Using Standard Dialogs
        1. 8.1. USING DIALOGS IN GENERAL
          1. 8.1.1. Adding the Dialog to the Form
          2. 8.1.2. Initializing the Dialog
          3. 8.1.3. Displaying the Dialog and Checking the Return Result
          4. 8.1.4. Processing the Results
          5. 8.1.5. Putting It All Together
        2. 8.2. USING DIALOG PROPERTIES
        3. 8.3. USING FILE FILTERS
        4. 8.4. TRY IT
          1. 8.4.1. Lesson Requirements
          2. 8.4.2. Hints
          3. 8.4.3. Step-by-Step
        5. 8.5. EXERCISES
      9. 9. Creating and Displaying New Forms
        1. 9.1. ADDING NEW FORMS
        2. 9.2. UNDERSTANDING CLASSES AND INSTANCES
        3. 9.3. DISPLAYING FORMS
        4. 9.4. CONTROLLING REMOTE FORMS
        5. 9.5. TRY IT
          1. 9.5.1. Lesson Requirements
          2. 9.5.2. Hints
          3. 9.5.3. Step-by-Step
        6. 9.6. EXERCISES
      10. 10. Building Custom Dialogs
        1. 10.1. MAKING CUSTOM DIALOGS
        2. 10.2. SETTING THE DIALOG RESULT
        3. 10.3. USING CUSTOM DIALOGS
        4. 10.4. TRY IT
          1. 10.4.1. Lesson Requirements
          2. 10.4.2. Hints
          3. 10.4.3. Step-by-Step
        5. 10.5. EXERCISES
    8. II. Variables and Calculations
      1. 11. Using Variables and Performing Calculations
        1. 11.1. WHAT ARE VARIABLES?
        2. 11.2. DATA TYPES
          1. 11.2.1. Single, Double, and Decimal Data Types
        3. 11.3. DECLARING VARIABLES
        4. 11.4. LITERAL VALUES
        5. 11.5. TYPE CONVERSIONS
          1. 11.5.1. Implicit Type Conversions
          2. 11.5.2. Explicit Type Conversions
            1. 11.5.2.1. Using Visual Basic Conversion Functions
            2. 11.5.2.2. Using CType
            3. 11.5.2.3. Using DirectCast and TryCast
            4. 11.5.2.4. Using Convert
            5. 11.5.2.5. Using Parsing
        6. 11.6. PERFORMING CALCULATIONS
          1. 11.6.1. Promotion
          2. 11.6.2. Operator Summary
            1. 11.6.2.1. Arithmetic Operators
            2. 11.6.2.2. Logical Operators
            3. 11.6.2.3. String Operators
            4. 11.6.2.4. Comparison Operators
            5. 11.6.2.5. Assignment Operators
            6. 11.6.2.6. Bitwise Operators
          3. 11.6.3. Precedence
        7. 11.7. CONSTANTS
        8. 11.8. TRY IT
          1. 11.8.1. Lesson Requirements
          2. 11.8.2. Hints
          3. 11.8.3. Step-by-Step
        9. 11.9. EXERCISES
      2. 12. Debugging Code
        1. 12.1. DEFERRED TECHNIQUES
        2. 12.2. DEBUGGING THEN AND NOW
        3. 12.3. SETTING BREAKPOINTS
        4. 12.4. READING VARIABLES
        5. 12.5. STEPPING THROUGH CODE
        6. 12.6. USING WATCHES
        7. 12.7. USING THE IMMEDIATE WINDOW
        8. 12.8. TRY IT
          1. 12.8.1. Lesson Requirements
          2. 12.8.2. Step-by-Step
        9. 12.9. EXERCISES
      3. 13. Understanding Scope
        1. 13.1. SCOPE WITHIN A CLASS
          1. 13.1.1. Same-Named Variables
          2. 13.1.2. Method Variable Lifetime
          3. 13.1.3. Block Scope
        2. 13.2. ACCESSIBILITY
        3. 13.3. RESTRICTING SCOPE AND ACCESSIBILITY
        4. 13.4. TRY IT
          1. 13.4.1. Lesson Requirements
          2. 13.4.2. Hints
          3. 13.4.3. Step-by-Step
        5. 13.5. EXERCISES
      4. 14. Working with Strings
        1. 14.1. STRING METHODS
        2. 14.2. FORMAT AND TOSTRING
          1. 14.2.1. Standard Numeric Formats
          2. 14.2.2. Custom Numeric Formats
          3. 14.2.3. Standard Date and Time Formats
          4. 14.2.4. Custom Date and Time Formats
        3. 14.3. TRY IT
          1. 14.3.1. Lesson Requirements
          2. 14.3.2. Hints
          3. 14.3.3. Step-by-Step
        4. 14.4. EXERCISES
      5. 15. Working with Dates and Times
        1. 15.1. CREATING DATE VARIABLES
        2. 15.2. LOCAL AND UTC TIME
        3. 15.3. DATE PROPERTIES AND METHODS
        4. 15.4. TIMESPANS
        5. 15.5. TRY IT
          1. 15.5.1. Lesson Requirements
          2. 15.5.2. Hints
          3. 15.5.3. Step-by-Step
        6. 15.6. EXERCISES
      6. 16. Using Arrays and Collections
        1. 16.1. ARRAYS
          1. 16.1.1. Creating Arrays
          2. 16.1.2. Multi-Dimensional Arrays
          3. 16.1.3. Array Properties and Methods
        2. 16.2. COLLECTION CLASSES
          1. 16.2.1. Generic Classes
          2. 16.2.2. Lists
          3. 16.2.3. SortedLists
          4. 16.2.4. Dictionaries
          5. 16.2.5. Queues
          6. 16.2.6. Stacks
        3. 16.3. TRY IT
          1. 16.3.1. Lesson Requirements
          2. 16.3.2. Step-by-Step
        4. 16.4. EXERCISES
      7. 17. Using Enumerations and Structures
        1. 17.1. ENUMERATIONS
        2. 17.2. STRUCTURES
        3. 17.3. STRUCTURES VERSUS CLASSES
        4. 17.4. TRY IT
          1. 17.4.1. Lesson Requirements
          2. 17.4.2. Hints
          3. 17.4.3. Step-by-Step
        5. 17.5. EXERCISES
    9. III. Program Statements
      1. 18. Making Choices
        1. 18.1. DECISION STATEMENTS
        2. 18.2. IF STATEMENTS
        3. 18.3. IF THEN ELSE
        4. 18.4. ELSEIF STATEMENTS
        5. 18.5. NESTED IF STATEMENTS
        6. 18.6. SELECT CASE STATEMENTS
        7. 18.7. CASE TESTS
        8. 18.8. TRY IT
          1. 18.8.1. Lesson Requirements
          2. 18.8.2. Hints
          3. 18.8.3. Step-by-Step
        9. 18.9. EXERCISES
      2. 19. Repeating Program Steps
        1. 19.1. FOR LOOPS
        2. 19.2. FOR EACH LOOPS
        3. 19.3. WHILE LOOPS
        4. 19.4. DO LOOPS
        5. 19.5. EXIT AND CONTINUE
        6. 19.6. TRY IT
          1. 19.6.1. Lesson Requirements
          2. 19.6.2. Hints
          3. 19.6.3. Step-by-Step
        7. 19.7. EXERCISES
      3. 20. Reusing Code with Procedures
        1. 20.1. PROCEDURE ADVANTAGES
        2. 20.2. PROCEDURE SYNTAX
          1. 20.2.1. Subroutine Syntax
          2. 20.2.2. Function Syntax
          3. 20.2.3. Parameters
          4. 20.2.4. ByVal and ByRef
        3. 20.3. CODE MODULES
        4. 20.4. TRY IT
          1. 20.4.1. Lesson Requirements
          2. 20.4.2. Hints
          3. 20.4.3. Step-by-Step
        5. 20.5. EXERCISES
      4. 21. Handling Errors
        1. 21.1. ERRORS AND EXCEPTIONS
        2. 21.2. TRY CATCH BLOCKS
        3. 21.3. THROWING ERRORS
        4. 21.4. TRY IT
          1. 21.4.1. Lesson Requirements
          2. 21.4.2. Hints
          3. 21.4.3. STEP-BY-STEP
        5. 21.5. EXERCISES
      5. 22. Preventing Bugs
        1. 22.1. INPUT ASSERTIONS
        2. 22.2. OTHER ASSERTIONS
        3. 22.3. TRY IT
          1. 22.3.1. Lesson Requirements
          2. 22.3.2. HINTS
          3. 22.3.3. Step-By-Step
        4. 22.4. EXERCISES
    10. IV. Classes
      1. 23. Defining Classes and Their Properties
        1. 23.1. WHAT IS A CLASS?
        2. 23.2. CLASS BENEFITS
        3. 23.3. MAKING A CLASS
        4. 23.4. PROPERTIES
          1. 23.4.1. AUTO-IMPLEMENTED PROPERTIES
          2. 23.4.2. Backing Fields
        5. 23.5. TRY IT
          1. 23.5.1. Lesson Requirements
          2. 23.5.2. Hints
          3. 23.5.3. Step-By-Step
        6. 23.6. EXERCISES
      2. 24. Defining Class Methods and Events
        1. 24.1. METHODS
        2. 24.2. EVENTS
          1. 24.2.1. Declaring Events
          2. 24.2.2. Raising Events
          3. 24.2.3. Catching Events
        3. 24.3. TRY IT
          1. 24.3.1. Lesson Requirements
          2. 24.3.2. Hints
          3. 24.3.3. Step-by-Step
        4. 24.4. EXERCISES
      3. 25. Using Inheritance and Polymorphism
        1. 25.1. INHERITANCE
        2. 25.2. POLYMORPHISM
        3. 25.3. TRY IT
          1. 25.3.1. Lesson Requirements
          2. 25.3.2. Hints
          3. 25.3.3. Step-by-Step
        4. 25.4. EXERCISES
      4. 26. Initializing Objects
        1. 26.1. INITIALIZING OBJECTS
        2. 26.2. CONSTRUCTORS
          1. 26.2.1. Parameterless Constructors
          2. 26.2.2. Parameterized Constructors
        3. 26.3. INVOKING OTHER CONSTRUCTORS
        4. 26.4. TRY IT
          1. 26.4.1. Lesson Requirements
          2. 26.4.2. Hints
          3. 26.4.3. Step-by-Step
        5. 26.5. EXERCISES
      5. 27. Fine-Tuning Classes
        1. 27.1. OVERLOADING METHODS
        2. 27.2. OVERRIDING METHODS
        3. 27.3. TRY IT
          1. 27.3.1. Lesson Requirements
          2. 27.3.2. Hints
          3. 27.3.3. Step-by-Step
        4. 27.4. EXERCISES
      6. 28. Overloading Operators
        1. 28.1. OVERLOADABLE OPERATORS
        2. 28.2. UNARY OPERATORS
        3. 28.3. BINARY OPERATORS
        4. 28.4. COMPARISON OPERATORS
        5. 28.5. CTYPE
        6. 28.6. TRY IT
          1. 28.6.1. Lesson Requirements
          2. 28.6.2. Hints
          3. 28.6.3. Step-by-Step
        7. 28.7. EXERCISES
      7. 29. Using Interfaces
        1. 29.1. INTERFACE ADVANTAGES
          1. 29.1.1. Multiple Inheritance
          2. 29.1.2. Code Generalization
        2. 29.2. IMPLEMENTING INTERFACES
        3. 29.3. DEFINING INTERFACES
        4. 29.4. TRY IT
          1. 29.4.1. Lesson Requirements
          2. 29.4.2. Hints
          3. 29.4.3. Step-by-Step
        5. 29.5. EXERCISES
      8. 30. Making Generic Classes
        1. 30.1. DEFINING GENERIC CLASSES
        2. 30.2. USING GENERIC CONSTRAINTS
        3. 30.3. MAKING GENERIC METHODS
        4. 30.4. TRY IT
          1. 30.4.1. Lesson Requirements
          2. 30.4.2. Hints
          3. 30.4.3. Step-by-Step
        5. 30.5. EXERCISES
    11. V. System Interactions
      1. 31. Reading and Writing Files
        1. 31.1. UNDERSTANDING STREAMS
        2. 31.2. WRITING FILES
        3. 31.3. READING FILES
        4. 31.4. TRY IT
          1. 31.4.1. Lesson Requirements
          2. 31.4.2. Hints
          3. 31.4.3. Step-by-Step
        5. 31.5. EXERCISES
      2. 32. Using File System Classes
        1. 32.1. THE DRIVEINFO CLASS
        2. 32.2. THE DIRECTORYINFO CLASS
        3. 32.3. THE DIRECTORY CLASS
        4. 32.4. THE FILEINFO CLASS
        5. 32.5. THE FILE CLASS
        6. 32.6. THE PATH CLASS
        7. 32.7. TRY IT
          1. 32.7.1. Lesson Requirements
          2. 32.7.2. Hints
          3. 32.7.3. Step-by-Step
        8. 32.8. EXERCISES
      3. 33. Printing
        1. 33.1. BASIC PRINTING
          1. 33.1.1. Drawing Shapes
          2. 33.1.2. Drawing Text
        2. 33.2. TRY IT
          1. 33.2.1. Lesson Requirements
          2. 33.2.2. Hints
          3. 33.2.3. Step-by-Step
        3. 33.3. EXERCISES
      4. 34. Using the Clipboard
        1. 34.1. ADDING DATA TO THE CLIPBOARD
        2. 34.2. GETTING DATA FROM THE CLIPBOARD
        3. 34.3. TRY IT
          1. 34.3.1. Lesson Requirements
          2. 34.3.2. Hints
          3. 34.3.3. Step-by-Step
        4. 34.4. EXERCISES
      5. 35. Providing Drag and Drop
        1. 35.1. UNDERSTANDING DRAG AND DROP EVENTS
        2. 35.2. STARTING A DRAG
        3. 35.3. CATCHING A DROP
        4. 35.4. TRY IT
          1. 35.4.1. Lesson Requirements
          2. 35.4.2. Hints
          3. 35.4.3. Step-by-Step
        5. 35.5. EXERCISES
    12. VI. Specialized Topics
      1. 36. Using the My Namespace
        1. 36.1. MY SUB-NAMESPACES
          1. 36.1.1. My.Application
          2. 36.1.2. My.Computer
          3. 36.1.3. My.Forms
          4. 36.1.4. My.Resources
          5. 36.1.5. My.Settings
          6. 36.1.6. My.User
        2. 36.2. TRY IT
          1. 36.2.1. Lesson Requirements
          2. 36.2.2. Hints
          3. 36.2.3. Step-by-Step
        3. 36.3. EXERCISES
      2. 37. Localizing Programs
        1. 37.1. UNDERSTANDING LOCALIZATION
        2. 37.2. BUILDING LOCALIZED INTERFACES
        3. 37.3. PROCESSING LOCALE-SPECIFIC VALUES
        4. 37.4. TRY IT
          1. 37.4.1. Lesson Requirements
          2. 37.4.2. Hints
          3. 37.4.3. Step-by-Step
        5. 37.5. EXERCISES
      3. 38. Manipulating Data with LINQ to Objects
        1. 38.1. LINQ BASICS
        2. 38.2. WHERE CLAUSES
        3. 38.3. ORDER BY CLAUSES
        4. 38.4. SELECT CLAUSES
        5. 38.5. TRY IT
          1. 38.5.1. Lesson Requirements
          2. 38.5.2. Hints
          3. 38.5.3. Step-by-Step
        6. 38.6. EXERCISES
      4. 39. Manipulating Databases with the Entity Framework
        1. 39.1. ENTITY FRAMEWORK FEATURES
        2. 39.2. USING THE ENTITY FRAMEWORK: A BASIC APPROACH
          1. 39.2.1. Building a SQL Server Database
          2. 39.2.2. Making the Data Model and Classes
        3. 39.3. USING THE ENTITY FRAMEWORK CLASSES
        4. 39.4. TRY IT
          1. 39.4.1. Lesson Requirements
          2. 39.4.2. Hints
          3. 39.4.3. Step-by-Step
        5. 39.5. EXERCISES
      5. A. Glossary
      6. B. Control Summary
      7. C. What's on the DVD?
        1. C.1. SYSTEM REQUIREMENTS
        2. C.2. USING THE DVD
        3. C.3. WHAT'S ON THE DVD
        4. C.4. TROUBLESHOOTING
        5. C.5. CUSTOMER CARE