Mastering Microsoft® Visual Basic® 2010

Book description

The new edition of the ultimate comprehensive guide to Microsoft Visual Basic

Where most VB books start with beginner level topics, Mastering Visual Basic 2010 vaults you right into intermediate and advanced coverage. From the core of the language and user interface design to developing data-driven applications, this detailed book brings you thoroughly up to speed and features numerous example programs you can use to start building your own apps right away.

  • Covers Visual Basic 2010, part of Microsoft's Visual Studio integrated development environment (IDE), which includes C#, C++, Visual Web Developer, and ASP.NET, along with Visual Basic

  • Explains topics in the thorough, step-by-step style of all books in the Mastering series, providing you ample instruction, tips, and techniques

  • Helps you build your own applications by supplying sample code you can use to start development

  • Includes review exercises in each chapter to reinforce concepts as you learn

All the books in the Sybex Mastering series feature comprehensive and expert coverage of topics you can put to immediate use.

Table of contents

  1. Copyright
  2. Dear Reader,
  3. Acknowledgments
  4. About the Author
  5. Introduction
    1. The Mastering Series
    2. Who Should Read This Book?
    3. How about the Advanced Topics?
    4. The Structure of the Book
      1. Don't Miss the Tutorials
    5. Downloading This Book's Code
  6. 1. Visual Basic: The Language
    1. 1. Getting Started with Visual Basic 2010
      1. 1.1. Exploring the Integrated Development Environment
        1. 1.1.1. The Start Page
        2. 1.1.2. Starting a New Project
        3. 1.1.3. Using the Windows Form Designer
      2. 1.2. Creating Your First VB Application
        1. 1.2.1. Making the Application More User Friendly
      3. 1.3. Understanding the IDE Components
        1. 1.3.1. The IDE Menus
          1. 1.3.1.1. File Menu
          2. 1.3.1.2. Edit Menu
            1. 1.3.1.2.1. Edit Advanced Submenu
            2. 1.3.1.2.2. Edit IntelliSense Submenu
            3. 1.3.1.2.3. Edit Outlining Submenu
          3. 1.3.1.3. View Menu
          4. 1.3.1.4. Project Menu
          5. 1.3.1.5. Build Menu
          6. 1.3.1.6. Debug Menu
          7. 1.3.1.7. Data Menu
          8. 1.3.1.8. Format Menu
          9. 1.3.1.9. Tools Menu
          10. 1.3.1.10. Window Menu
          11. 1.3.1.11. Help Menu
        2. 1.3.2. The Toolbox Window
        3. 1.3.3. The Solution Explorer Window
        4. 1.3.4. The Properties Window
        5. 1.3.5. The Output Window
        6. 1.3.6. The Command and Immediate Windows
        7. 1.3.7. The Error List Window
      4. 1.4. Setting Environment Options
      5. 1.5. Building a Console Application
      6. 1.6. Using Code Snippets
      7. 1.7. Using the My Component
      8. 1.8. The Bottom Line
    2. 2. Handling Data
      1. 2.1. Variables
        1. 2.1.1. Declaring Variables
          1. 2.1.1.1. Variable-Naming Conventions
          2. 2.1.1.2. Variable Initialization
        2. 2.1.2. Types of Variables
          1. 2.1.2.1. Numeric Variables
            1. 2.1.2.1.1. Integer Variables
            2. 2.1.2.1.2. Single- and Double-Precision Numbers
            3. 2.1.2.1.3. The Decimal Data Type
          2. 2.1.2.2. Infinity and Other Oddities
            1. 2.1.2.2.1. Testing for Infinity and NaN
          3. 2.1.2.3. Byte Variables
          4. 2.1.2.4. Boolean Variables
          5. 2.1.2.5. String Variables
          6. 2.1.2.6. Character Variables
          7. 2.1.2.7. Date Variables
        3. 2.1.3. The Strict, Explicit, and Infer Options
          1. 2.1.3.1. Type Inference
        4. 2.1.4. Object Variables
      2. 2.2. Variables as Objects
        1. 2.2.1. Converting Variable Types
          1. 2.2.1.1. Widening and Narrowing Conversions
        2. 2.2.2. Formatting Numbers
          1. 2.2.2.1. Standard Numeric Format Strings
          2. 2.2.2.2. Picture Numeric Format Strings
        3. 2.2.3. User-Defined Data Types
        4. 2.2.4. Examining Variable Types
          1. 2.2.4.1. Is It a Number, String, or Date?
        5. 2.2.5. A Variable's Scope
        6. 2.2.6. A Variable's Lifetime
      3. 2.3. Constants
      4. 2.4. Arrays
        1. 2.4.1. Declaring Arrays
        2. 2.4.2. Initializing Arrays
          1. 2.4.2.1. Array Limits
        3. 2.4.3. Multidimensional Arrays
        4. 2.4.4. Collections
      5. 2.5. The Bottom Line
    3. 3. Visual Basic Programming Essentials
      1. 3.1. Flow-Control Statements
        1. 3.1.1. Decision Statements
          1. 3.1.1.1. If...Then Statements
          2. 3.1.1.2. If...Then...Else Statements
          3. 3.1.1.3. Select Case Statements
          4. 3.1.1.4. Short-Circuiting Expression Evaluation
        2. 3.1.2. Loop Statements
          1. 3.1.2.1. For...Next Loops
          2. 3.1.2.2. For Each...Next Loops
          3. 3.1.2.3. Do Loops
          4. 3.1.2.4. While Loops
        3. 3.1.3. Nested Control Structures
        4. 3.1.4. The Exit and Continue Statements
      2. 3.2. Writing and Using Procedures
        1. 3.2.1. Subroutines
        2. 3.2.2. Functions
      3. 3.3. Arguments
        1. 3.3.1. Argument-Passing Mechanisms
          1. 3.3.1.1. By Value versus by Reference
          2. 3.3.1.2. Returning Multiple Values
        2. 3.3.2. Built-in Functions
        3. 3.3.3. Custom Functions
        4. 3.3.4. Passing Arguments and Returning Values
          1. 3.3.4.1. Passing an Unknown Number of Arguments
          2. 3.3.4.2. Named Arguments
          3. 3.3.4.3. Functions Returning Arrays
        5. 3.3.5. Overloading Functions
          1. 3.3.5.1. VB2010 at Work: The OverloadedFunctions Project
          2. 3.3.5.2. Documenting Functions
      4. 3.4. The Bottom Line
  7. 2. Developing Windows Applications
    1. 4. GUI Design and Event-Driven Programming
      1. 4.1. On Designing Windows Applications
      2. 4.2. Building a Loan Calculator
        1. 4.2.1. Understanding How the Loan Calculator Application Works
        2. 4.2.2. Designing the User Interface
          1. 4.2.2.1. Aligning the Controls
        3. 4.2.3. Programming the Loan Application
        4. 4.2.4. Validating the Data
      3. 4.3. Building a Calculator
        1. 4.3.1. Designing the User Interface
        2. 4.3.2. Programming the MathCalculator
          1. 4.3.2.1. Coding the Math Operations
        3. 4.3.3. Using the Basic Debugging Tools
        4. 4.3.4. Exception Handling
      4. 4.4. The Bottom Line
    2. 5. Basic Windows Controls
      1. 5.1. The TextBox Control
        1. 5.1.1. Basic Properties
          1. 5.1.1.1. TextAlign
          2. 5.1.1.2. MultiLine
          3. 5.1.1.3. MaxLength
          4. 5.1.1.4. ScrollBars
          5. 5.1.1.5. WordWrap
          6. 5.1.1.6. AcceptsReturn, AcceptsTab
          7. 5.1.1.7. CharacterCasing
          8. 5.1.1.8. PasswordChar
          9. 5.1.1.9. ReadOnly, Locked
        2. 5.1.2. Text-Manipulation Properties
          1. 5.1.2.1. Text
          2. 5.1.2.2. Lines
        3. 5.1.3. Text-Selection Properties
          1. 5.1.3.1. SelectedText
          2. 5.1.3.2. SelectionStart, SelectionLength
          3. 5.1.3.3. HideSelection
        4. 5.1.4. Undoing Edits
        5. 5.1.5. VB 2010 at Work: The TextPad Project
          1. 5.1.5.1. The Editing Commands
          2. 5.1.5.2. The Process and Format Menus
          3. 5.1.5.3. Search and Replace Operations
          4. 5.1.5.4. The Undo/Redo Commands
        6. 5.1.6. Capturing Keystrokes
          1. 5.1.6.1. Capturing Function Keys
        7. 5.1.7. Autocomplete Properties
      2. 5.2. The ListBox, CheckedListBox, and ComboBox Controls
        1. 5.2.1. Basic Properties
          1. 5.2.1.1. IntegralHeight
          2. 5.2.1.2. Items
          3. 5.2.1.3. MultiColumn
          4. 5.2.1.4. SelectionMode
          5. 5.2.1.5. Sorted
          6. 5.2.1.6. Text
        2. 5.2.2. Manipulating the Items Collection
          1. 5.2.2.1. The Add Method
          2. 5.2.2.2. The Insert Method
          3. 5.2.2.3. The Clear Method
          4. 5.2.2.4. The Count Property
          5. 5.2.2.5. The CopyTo Method
          6. 5.2.2.6. The Remove and RemoveAt Methods
          7. 5.2.2.7. The Contains Method
        3. 5.2.3. Selecting Items
        4. 5.2.4. VB 2010 at Work: The ListBox Demo Project
          1. 5.2.4.1. The Add Item Buttons
          2. 5.2.4.2. Removing Items from the Two Lists
          3. 5.2.4.3. Moving Items Between Lists
        5. 5.2.5. Searching the ListBox
          1. 5.2.5.1. VB 2010 at Work: The ListBoxFind Application
        6. 5.2.6. The ComboBox Control
          1. 5.2.6.1. Adding Items to a ComboBox at Runtime
          2. 5.2.6.2. VB 2010 At Work: The FlexCombo Project
      3. 5.3. The ScrollBar and TrackBar Controls
        1. 5.3.1. The ScrollBar Control
          1. 5.3.1.1. VB 2010 at Work: The Colors Project
          2. 5.3.1.2. The ScrollBar Control's Events
          3. 5.3.1.3. Handling the Events in the Colors Application
        2. 5.3.2. The TrackBar Control
          1. 5.3.2.1. VB 2010 at Work: The Inches Project
      4. 5.4. The Bottom Line
    3. 6. Working with Forms
      1. 6.1. The Appearance of Forms
        1. 6.1.1. Properties of the Form Object
          1. 6.1.1.1. AcceptButton, CancelButton
          2. 6.1.1.2. AutoScaleMode
          3. 6.1.1.3. AutoScroll
          4. 6.1.1.4. AutoScrollPosition
          5. 6.1.1.5. AutoScrollMargin
          6. 6.1.1.6. AutoScrollMinSize
          7. 6.1.1.7. FormBorderStyle
          8. 6.1.1.8. ControlBox
          9. 6.1.1.9. MinimizeBox, MaximizeBox
          10. 6.1.1.10. MinimumSize, MaximumSize
          11. 6.1.1.11. KeyPreview
          12. 6.1.1.12. SizeGripStyle
          13. 6.1.1.13. StartPosition, Location
          14. 6.1.1.14. TopMost
          15. 6.1.1.15. Size
        2. 6.1.2. Placing Controls on Forms
        3. 6.1.3. Setting the TabIndex Property
        4. 6.1.4. VB 2010 at Work: The Contacts Project
          1. 6.1.4.1. Handling Keystrokes
        5. 6.1.5. Anchoring and Docking
          1. 6.1.5.1. Anchoring Controls
          2. 6.1.5.2. Docking Controls
        6. 6.1.6. Splitting Forms into Multiple Panes
        7. 6.1.7. Form Events
          1. 6.1.7.1. The Activated and Deactivate Events
          2. 6.1.7.2. The FormClosing and FormClosed Events
          3. 6.1.7.3. The Resize, ResizeBegin, and ResizeEnd Events
          4. 6.1.7.4. The Scroll Event
          5. 6.1.7.5. The Paint Event
      2. 6.2. Loading and Showing Forms
        1. 6.2.1. The Startup Form
        2. 6.2.2. Controlling One Form from within Another
          1. 6.2.2.1. Sharing Variables between Forms
        3. 6.2.3. Forms versus Dialog Boxes
          1. 6.2.3.1. VB 2010 at Work: The MultipleForms Project
      3. 6.3. Building Dynamic Forms at Runtime
        1. 6.3.1. The Form's Controls Collection
          1. 6.3.1.1. VB 2010 at Work: The ShowControls Project
          2. 6.3.1.2. VB 2010 at Work: The DynamicForm Project
        2. 6.3.2. Creating Event Handlers at Runtime
      4. 6.4. Designing Menus
        1. 6.4.1. The Menu Editor
        2. 6.4.2. The ToolStripMenuItem Properties
          1. 6.4.2.1. Programming Menu Commands
          2. 6.4.2.2. Using Access and Shortcut Keys
            1. 6.4.2.2.1. Access Keys
            2. 6.4.2.2.2. Shortcut Keys
        3. 6.4.3. Manipulating Menus at Runtime
          1. 6.4.3.1. Creating Short and Long Menus
          2. 6.4.3.2. Adding and Removing Commands at Runtime
          3. 6.4.3.3. Creating Context Menus
      5. 6.5. The Bottom Line
    4. 7. More Windows Controls
      1. 7.1. The Common Dialog Controls
        1. 7.1.1. Using the Common Dialog Controls
        2. 7.1.2. The ColorDialog Control
          1. 7.1.2.1. AllowFullOpen
          2. 7.1.2.2. AnyColor
          3. 7.1.2.3. Color
          4. 7.1.2.4. CustomColors
          5. 7.1.2.5. SolidColorOnly
        3. 7.1.3. The FontDialog Control
          1. 7.1.3.1. AllowScriptChange
          2. 7.1.3.2. AllowVerticalFonts
          3. 7.1.3.3. Color, ShowColor
          4. 7.1.3.4. FixedPitchOnly
          5. 7.1.3.5. Font
          6. 7.1.3.6. FontMustExist
          7. 7.1.3.7. MaxSize, MinSize
          8. 7.1.3.8. ShowApply
          9. 7.1.3.9. ShowEffects
        4. 7.1.4. The OpenDialog and SaveDialog Controls
          1. 7.1.4.1. AddExtension
          2. 7.1.4.2. CheckFileExists
          3. 7.1.4.3. CheckPathExists
          4. 7.1.4.4. DefaultExt
          5. 7.1.4.5. DereferenceLinks
          6. 7.1.4.6. FileName
          7. 7.1.4.7. Filter
          8. 7.1.4.8. FilterIndex
          9. 7.1.4.9. InitialDirectory
          10. 7.1.4.10. RestoreDirectory
          11. 7.1.4.11. FileNames
          12. 7.1.4.12. MultiSelect
          13. 7.1.4.13. ReadOnlyChecked, ShowReadOnly
          14. 7.1.4.14. The OpenFile and SaveFile Methods
          15. 7.1.4.15. VB 2010 at Work: Multiple File Selection
        5. 7.1.5. The FolderBrowserDialog Control
          1. 7.1.5.1. RootFolder
          2. 7.1.5.2. SelectedPath
          3. 7.1.5.3. ShowNewFolderButton
          4. 7.1.5.4. VB 2010 at Work: Folder Browsing Demo Project
      2. 7.2. The RichTextBox Control
        1. 7.2.1. The RTF Language
        2. 7.2.2. Text Manipulation and Formatting Properties
          1. 7.2.2.1. SelectedText
          2. 7.2.2.2. SelectionStart, SelectionLength
          3. 7.2.2.3. SelectionAlignment
          4. 7.2.2.4. SelectionIndent, SelectionRightIndent, SelectionHangingIndent
          5. 7.2.2.5. SelectionBullet, BulletIndent
          6. 7.2.2.6. SelectionTabs
        3. 7.2.3. Methods
          1. 7.2.3.1. SaveFile
          2. 7.2.3.2. LoadFile
          3. 7.2.3.3. Select, SelectAll
        4. 7.2.4. Advanced Editing Features
          1. 7.2.4.1. CanUndo, CanRedo
          2. 7.2.4.2. UndoActionName, RedoActionName
          3. 7.2.4.3. Undo, Redo
        5. 7.2.5. Cutting, Copying, and Pasting
        6. 7.2.6. VB 2010 at Work: The RTFPad Project
          1. 7.2.6.1. The File Menu
          2. 7.2.6.2. The Edit Menu
          3. 7.2.6.3. The Format Menu
          4. 7.2.6.4. The Search & Replace Dialog Box
      3. 7.3. The TreeView and ListView Controls
        1. 7.3.1. Tree and List Structures
        2. 7.3.2. The TreeView Control
          1. 7.3.2.1. Adding Nodes at Design Time
          2. 7.3.2.2. Adding Nodes at Runtime
            1. 7.3.2.2.1. Adding New Nodes
        3. 7.3.3. The ListView Control
          1. 7.3.3.1. The Columns Collection
          2. 7.3.3.2. ListView Items and Subitems
          3. 7.3.3.3. The Items Collection
          4. 7.3.3.4. The SubItems Collection
          5. 7.3.3.5. Processing Selected Items
        4. 7.3.4. VB 2010 at Work: The CustomExplorer Project
      4. 7.4. The Bottom Line
  8. 3. Working with Custom Classes and Controls
    1. 8. Working with Objects
      1. 8.1. Classes and Objects
      2. 8.2. What Is a Class?
        1. 8.2.1. Classes Combine Code with Data
      3. 8.3. Building the Minimal Class
        1. 8.3.1. Adding Code to the Minimal Class
        2. 8.3.2. Using Property Procedures
          1. 8.3.2.1. Throwing Exceptions
          2. 8.3.2.2. Implementing Read-Only Properties
            1. 8.3.2.2.1. Calculating Property Values on the Fly
          3. 8.3.2.3. Auto-Implemented Properties
        3. 8.3.3. Customizing Default Members
          1. 8.3.3.1. Customizing the ToString Method
          2. 8.3.3.2. Customizing the Equals Method
          3. 8.3.3.3. Know What You Are Comparing
          4. 8.3.3.4. The Is Operator
        4. 8.3.4. Custom Enumerations
          1. 8.3.4.1. VB 2010 at Work: The Contacts Project
            1. 8.3.4.1.1. Adding, Editing, and Deleting Contacts
        5. 8.3.5. Object Constructors
        6. 8.3.6. Using the SimpleClass in Other Projects
        7. 8.3.7. Firing Events
        8. 8.3.8. Instance and Shared Methods
      4. 8.4. A "Real" Class
        1. 8.4.1. Nesting Classes
      5. 8.5. Operator Overloading
        1. 8.5.1. VB 2010 at Work: The LengthUnits Class
          1. 8.5.1.1. Implementing Unary Operators
          2. 8.5.1.2. Handling Variants
      6. 8.6. The Bottom Line
    2. 9. Building Custom Windows Controls
      1. 9.1. On Designing Windows Controls
      2. 9.2. Enhancing Existing Controls
        1. 9.2.1. Building the FocusedTextBox Control
          1. 9.2.1.1. Adding Functionality to Your Custom Control
          2. 9.2.1.2. Testing the FocusedTextBox Control
          3. 9.2.1.3. Classifying the Control's Properties
      3. 9.3. Building Compound Controls
        1. 9.3.1. VB 2010 at Work: The ColorEdit Control
          1. 9.3.1.1. Testing the ColorEdit Control
      4. 9.4. Building User-Drawn Controls
        1. 9.4.1. VB 2010 at Work: The Label3D Control
          1. 9.4.1.1. Label3D Control Specifications
          2. 9.4.1.2. Designing the Custom Control
          3. 9.4.1.3. Testing Your New Control
          4. 9.4.1.4. Changed Events
        2. 9.4.2. Raising Custom Events
        3. 9.4.3. Using the Custom Control in Other Projects
      5. 9.5. Designing Irregularly Shaped Controls
      6. 9.6. Customizing List Controls
        1. 9.6.1. Designing Owner-Drawn ListBox Controls
      7. 9.7. The Bottom Line
    3. 10. Applied Object-Oriented Programming
      1. 10.1. Issues in Object-Oriented Programming
        1. 10.1.1. Classes versus Objects
        2. 10.1.2. Objects versus Object Variables
          1. 10.1.2.1. Uninitialized and Nullable Variables
          2. 10.1.2.2. Exploring Value Types
          3. 10.1.2.3. Exploring Reference Types
        3. 10.1.3. Properties versus Fields
        4. 10.1.4. Shared versus Instance Members
        5. 10.1.5. Type Casting
        6. 10.1.6. Early versus Late Binding
        7. 10.1.7. Discovering a Variable's Type
      2. 10.2. Inheritance
        1. 10.2.1. How to Apply Inheritance
        2. 10.2.2. Designing with Inheritance
      3. 10.3. Extension Methods
      4. 10.4. Polymorphism
        1. 10.4.1. Building the Shape Class
          1. 10.4.1.1. Testing the Shape Class
      5. 10.5. Who Can Inherit What?
        1. 10.5.1. Parent Class Keywords
        2. 10.5.2. Derived Class Keywords
        3. 10.5.3. Parent Class Member Keywords
        4. 10.5.4. Derived Class Member Keyword
        5. 10.5.5. VB 2010 At Work: The InheritanceKeywords Project
        6. 10.5.6. MyBase and MyClass
        7. 10.5.7. Putting Inheritance to Work
        8. 10.5.8. The Class Diagram Designer
      6. 10.6. The Bottom Line
  9. 4. Working with the .NET Framework
    1. 11. The Framework at Large
      1. 11.1. What Is the Framework?
      2. 11.2. Using Snippets
      3. 11.3. Using the My Component
        1. 11.3.1.
          1. 11.3.1.1. My.Application
          2. 11.3.1.2. My.Computer
          3. 11.3.1.3. My.Forms
          4. 11.3.1.4. My.Settings
          5. 11.3.1.5. My.User
          6. 11.3.1.6. My.WebServices
        2. 11.3.2. How to Use the My Component
      4. 11.4. The IO Namespace
        1. 11.4.1. The Directory Class
        2. 11.4.2. The File Class
        3. 11.4.3. The DriveInfo Class
        4. 11.4.4. The DirectoryInfo Class
        5. 11.4.5. The Path Class
        6. 11.4.6. Streaming Data
      5. 11.5. Drawing and Painting
        1. 11.5.1.
          1. 11.5.1.1. The Graphics Object
          2. 11.5.1.2. The Point Class
          3. 11.5.1.3. The Rectangle Class
          4. 11.5.1.4. The Size Class
          5. 11.5.1.5. The Color Class
          6. 11.5.1.6. The Font Class
          7. 11.5.1.7. The Pen Class
          8. 11.5.1.8. The Brush Class
        2. 11.5.2. Drawing Methods
        3. 11.5.3. Gradients
      6. 11.6. The Image Class
      7. 11.7. Printing
        1. 11.7.1. The PrintDocument Control
        2. 11.7.2. The PrintDialog Control
        3. 11.7.3. The PageSetupDialog Control
        4. 11.7.4. The PrintPreviewDialog Control
        5. 11.7.5. Page Geometry
        6. 11.7.6. Basic Printing Methods
        7. 11.7.7. VB 2010 at Work: Generating a Simple Printout
      8. 11.8. Handling Strings and Characters
        1. 11.8.1. The Char Class
          1. 11.8.1.1. Properties
          2. 11.8.1.2. Methods
        2. 11.8.2. The String Class
          1. 11.8.2.1. Properties
          2. 11.8.2.2. Methods
        3. 11.8.3. The StringBuilder Class
          1. 11.8.3.1. Properties
          2. 11.8.3.2. Methods
          3. 11.8.3.3. VB 2010 at Work: Test-Driving the StringBuilder Class
      9. 11.9. Handling Dates and Time
        1. 11.9.1. The DateTime Class
          1. 11.9.1.1. Properties
          2. 11.9.1.2. Methods
          3. 11.9.1.3. Date Conversion Methods
          4. 11.9.1.4. Dates as Numeric Values
        2. 11.9.2. The TimeSpan Class
          1. 11.9.2.1. Properties
            1. 11.9.2.1.1. Field Properties
            2. 11.9.2.1.2. Interval Properties
          2. 11.9.2.2. Methods
        3. 11.9.3. The StopWatch Class
      10. 11.10. The Bottom Line
    2. 12. Storing Data in Collections
      1. 12.1. Advanced Array Topics
        1. 12.1.1. Sorting Arrays
        2. 12.1.2. Searching Arrays
          1. 12.1.2.1. VB 2010 at Work: The ArraySearch Application
          2. 12.1.2.2. The Binary Search Algorithm
        3. 12.1.3. Performing Other Array Operations
          1. 12.1.3.1. Array Limitations
      2. 12.2. Collection Types
        1. 12.2.1. Creating Collections
          1. 12.2.1.1. Adding and Removing List Items
          2. 12.2.1.2. Collection Initializers
          3. 12.2.1.3. Extracting Items from a Collection
        2. 12.2.2. Sorting Lists
        3. 12.2.3. Searching Lists
        4. 12.2.4. Iterating Through a List
      3. 12.3. The Dictionary Collection
      4. 12.4. The HashTable Collection
        1. 12.4.1. VB 2010 at Work: The WordFrequencies Project
      5. 12.5. The SortedList Collection
      6. 12.6. Other Collections
      7. 12.7. The IEnumerator and IComparer Interfaces
        1. 12.7.1. Enumerating Collections
        2. 12.7.2. Custom Sorting
          1. 12.7.2.1. Implementing the IComparer Interface
          2. 12.7.2.2. Implementing Multiple Comparers
      8. 12.8. The Bottom Line
    3. 13. XML in Modern Programming
      1. 13.1. A Very Quick Introduction to XML
        1. 13.1.1. XML Schema
        2. 13.1.2. Numbers and Dates in XML
      2. 13.2. Manipulating XML with VB
        1. 13.2.1. XML as a Data Type
        2. 13.2.2. Saving and Loading XML Documents
      3. 13.3. Traversing XML Documents
        1. 13.3.1. The Element and Elements Methods
        2. 13.3.2. Ancestors and Descendants Methods
        3. 13.3.3. Attribute Property
        4. 13.3.4. VB Axis Properties
        5. 13.3.5. Editing XML Documents
      4. 13.4. VB 2010 at Work: Manipulating XML Data
        1. 13.4.1. Locating Information in the Document
        2. 13.4.2. Editing the Document
        3. 13.4.3. Using XML Segments as Literals
        4. 13.4.4. Using Lambda Expressions
      5. 13.5. XML Serialization
        1. 13.5.1. The Serialization Process
        2. 13.5.2. Serializing Individual Objects
        3. 13.5.3. Serializing Custom Objects
        4. 13.5.4. Serializing Collections of Objects
      6. 13.6. Other Types of Serialization
        1. 13.6.1. Deserializing Individual Objects
          1. 13.6.1.1. Serializing Collections
      7. 13.7. The Bottom Line
    4. 14. An Introduction to LINQ
      1. 14.1. What Is LINQ?
        1. 14.1.1. LINQ Components
      2. 14.2. LINQ to Objects
        1. 14.2.1. Anonymous Types and Extension Methods
        2. 14.2.2. Querying Arbitrary Collections
        3. 14.2.3. Aggregating with LINQ
        4. 14.2.4. Some Practical LINQ Examples
          1. 14.2.4.1. Grouping and Aggregating
        5. 14.2.5. Transforming Objects with LINQ
      3. 14.3. LINQ to XML
        1. 14.3.1. Adding Dynamic Content to an XML Document
          1. 14.3.1.1. Transforming XML Documents
          2. 14.3.1.2. Working with XML Files
      4. 14.4. LINQ to SQL
        1. 14.4.1. Retrieving Data with the ExecuteQuery Method
        2. 14.4.2. Working with LINQ to SQL Classes
          1. 14.4.2.1. The DataContext Object
          2. 14.4.2.2. Accessing the Tables with LINQ
        3. 14.4.3. Navigation Methods
        4. 14.4.4. Updates
          1. 14.4.4.1. Creating a New Order
      5. 14.5. The Bottom Line
  10. 5. Developing Data-Driven Applications
    1. 15. Programming with ADO.NET
      1. 15.1. What Is a Database?
        1. 15.1.1. Using Relational Databases
        2. 15.1.2. Obtaining the Northwind and Pubs Sample Databases
        3. 15.1.3. Exploring the Northwind Database
          1. 15.1.3.1. Products Table
          2. 15.1.3.2. Suppliers Table
          3. 15.1.3.3. Categories Table
          4. 15.1.3.4. Customers Table
          5. 15.1.3.5. Orders Table
          6. 15.1.3.6. Order Details Table
          7. 15.1.3.7. Employees Table
          8. 15.1.3.8. Shippers Table
        4. 15.1.4. Exploring the Pubs Database
          1. 15.1.4.1. Titles Table
          2. 15.1.4.2. Authors Table
          3. 15.1.4.3. TitleAuthor Table
          4. 15.1.4.4. Publishers Table
        5. 15.1.5. Understanding Relations
          1. 15.1.5.1. Referential Integrity
          2. 15.1.5.2. Visual Database Tools
      2. 15.2. SQL: An Overview
        1. 15.2.1. Executing SQL Statements
          1. 15.2.1.1. Using SQL Server Management Studio
          2. 15.2.1.2. Using Visual Studio
        2. 15.2.2. Selection Queries
          1. 15.2.2.1. Limiting the Selection with WHERE
          2. 15.2.2.2. Combining Data from Multiple Tables
          3. 15.2.2.3. Aliasing Table Names
          4. 15.2.2.4. Aliasing Column Names
          5. 15.2.2.5. Skipping Duplicates with DISTINCT
          6. 15.2.2.6. The LIKE Operator
          7. 15.2.2.7. Null Values and the ISNULL Function
          8. 15.2.2.8. Sorting the Rows with ORDER BY
        3. 15.2.3. Working with Calculated Fields
        4. 15.2.4. Calculating Aggregates
        5. 15.2.5. Using SQL Joins
          1. 15.2.5.1. Left Joins
          2. 15.2.5.2. Right Joins
          3. 15.2.5.3. Full Joins
          4. 15.2.5.4. Inner Joins
        6. 15.2.6. Grouping Rows
          1. 15.2.6.1. Limiting Groups with HAVING
      3. 15.3. Action Queries
        1. 15.3.1. Deleting Rows
        2. 15.3.2. Inserting New Rows
        3. 15.3.3. Editing Existing Rows
      4. 15.4. Stream- versus Set-Based Data Access
      5. 15.5. The Basic Data-Access Classes
        1. 15.5.1. The Connection Class
        2. 15.5.2. The Command Class
          1. 15.5.2.1. Executing Stored Procedures
          2. 15.5.2.2. Executing Selection Queries
          3. 15.5.2.3. Using Commands with Parameters
          4. 15.5.2.4. Retrieving Multiple Values from a Stored Procedure
          5. 15.5.2.5. Handling Special Characters
          6. 15.5.2.6. Empty Strings versus Null Values
        3. 15.5.3. The DataReader Class
          1. 15.5.3.1. Reading Multiple Result Sets
          2. 15.5.3.2. VB 2010 at Work: Building a Simple Data-Driven Application
      6. 15.6. The Bottom Line
    2. 16. Developing Data-Driven Applications
      1. 16.1. Using Business Objects
        1. 16.1.1. VB 2010 at Work: The NWOrders Application
          1. 16.1.1.1. The Application's Interface
          2. 16.1.1.2. Implementing the Data-Access Layer with Custom Objects
            1. 16.1.1.2.1. Creating a New Order
            2. 16.1.1.2.2. Saving the New Order
          3. 16.1.1.3. Implementing the Data-Access Layer with LINQ to SQL
          4. 16.1.1.4. Using the TransactionScope Class
      2. 16.2. Storing Data in DataSets
        1. 16.2.1. Filling DataSets
          1. 16.2.1.1. The DataAdapter Class
            1. 16.2.1.1.1. Passing Parameters Through the DataAdapter
          2. 16.2.1.2. The CommandBuilder Class
        2. 16.2.2. Accessing the DataSet's Tables
        3. 16.2.3. Working with Rows
        4. 16.2.4. Handling Null Values
        5. 16.2.5. Adding and Deleting Rows
        6. 16.2.6. Navigating Through a DataSet
          1. 16.2.6.1. Row States and Versions
      3. 16.3. Performing Update Operations
        1. 16.3.1. Updating the Database with the DataAdapter
        2. 16.3.2. Handling Identity Columns
      4. 16.4. VB 2010 at Work: The SimpleDataSet Project
      5. 16.5. The Bottom Line
    3. 17. Using the Entity Data Model
      1. 17.1. The Entity Framework: Raising the Data Abstraction Bar
        1. 17.1.1. How Will You Benefit from the Entity Framework?
          1. 17.1.1.1. Preserving the Expressiveness of the Data Model
          2. 17.1.1.2. A Richer Set of Modeling Constructs for Representing Data
            1. 17.1.1.2.1. Complex Type for Complex Properties
            2. 17.1.1.2.2. Many-to-Many as a Simple Relation Between Entities
            3. 17.1.1.2.3. Inheritance Applied to Data
          3. 17.1.1.3. Data Store Technology and Brand Independence
          4. 17.1.1.4. Isolating the Application from the Data Structural Changes
        2. 17.1.2. Entity Data Model: Model-First Approach
          1. 17.1.2.1. Using the EDM Designer
          2. 17.1.2.2. Creating a New Entity Data Model
          3. 17.1.2.3. Connecting the EDM to a Database
          4. 17.1.2.4. Creating an Entity
          5. 17.1.2.5. Creating a Primary Key
          6. 17.1.2.6. Creating a Scalar Property
          7. 17.1.2.7. Entity Data Model Under the Hood
            1. 17.1.2.7.1. The Conceptual Model: The CSDL Content
            2. 17.1.2.7.2. The Logical Model: The SSDL Content
            3. 17.1.2.7.3. The Mapping Specification: C-S Mapping Content
            4. 17.1.2.7.4. Data as Objects in the Entity Framework
          8. 17.1.2.8. Adding an Inheritance Relationship Between Entities
            1. 17.1.2.8.1. Entity Framework Inheritance Mapping
          9. 17.1.2.9. Adding a Complex Property to an Entity
          10. 17.1.2.10. Adding a One-to-Many Association
          11. 17.1.2.11. Adding a Many-to-Many Association
          12. 17.1.2.12. Generate the Database Structure
      2. 17.2. Putting the EDM to Work
        1. 17.2.1. Querying the Entity Data Model
          1. 17.2.1.1. Using LINQ to Entities
            1. 17.2.1.1.1. Listing All of the Entities in a Database
            2. 17.2.1.1.2. Finding an Entity Using a LINQ Query
            3. 17.2.1.1.3. Finding an Entity of a Specific Type in the Inheritance Hierarchy
          2. 17.2.1.2. Using Entity SQL
          3. 17.2.1.3. Using Query Builder Methods and the ObjectQuery Class
          4. 17.2.1.4. Deferred Loading and Navigation Properties
            1. 17.2.1.4.1. Using the Include Method
            2. 17.2.1.4.2. Using Explicit Loading
            3. 17.2.1.4.3. Using Deferred Loading
            4. 17.2.1.4.4. Choosing the Right Loading Strategy
        2. 17.2.2. Modifying the Data with the Entity Framework
          1. 17.2.2.1. Inserting New Instances
          2. 17.2.2.2. Deleting an Entity Instance
          3. 17.2.2.3. Updating an Entity Instance
          4. 17.2.2.4. Establishing Relationship Between Entity Instances
          5. 17.2.2.5. Using Transactions in the Entity Framework
            1. 17.2.2.5.1. Coordinating Transactions with External Operations
      3. 17.3. Reverse-Engineering an Entity Data Model
      4. 17.4. The Bottom Line
    4. 18. Building Data-Bound Applications
      1. 18.1. Working with Typed DataSets
        1. 18.1.1. Generating a Typed DataSet
        2. 18.1.2. Exploring the Typed DataSet
      2. 18.2. Data Binding
        1. 18.2.1. Using the BindingSource Class
          1. 18.2.1.1. Handling Identity Columns
          2. 18.2.1.2. Adjusting the DataSet
      3. 18.3. Designing Data-Driven Interfaces the Easy Way
        1. 18.3.1. Enhancing the Navigational Tools
        2. 18.3.2. Binding Hierarchical Tables
          1. 18.3.2.1. Using the BindingSource as a Data Source
        3. 18.3.3. Adjusting the Appearance of the DataGridView Control
          1. 18.3.3.1. Displaying Lookup Columns in a DataGridView Control
        4. 18.3.4. Editing the Data in Hierarchical Tables
          1. 18.3.4.1. Updating Hierarchical DataSets
        5. 18.3.5. Building More-Functional Interfaces
          1. 18.3.5.1. Viewing the Deleted Rows
        6. 18.3.6. Data Binding with LINQ
          1. 18.3.6.1. Enabling the Binding with the DataView Class
          2. 18.3.6.2. Using LINQ to Filter Products Data
      4. 18.4. The Bottom Line
  11. 6. Developing for the Web
    1. 19. Accessing the Web
      1. 19.1. The WebBrowser Control
        1. 19.1.1. WebBrowser Control under the Hood
        2. 19.1.2. WebBrowser Control Properties
          1. 19.1.2.1. Dock
          2. 19.1.2.2. URL
          3. 19.1.2.3. AllowNavigation
          4. 19.1.2.4. ScrollBarsEnabled
          5. 19.1.2.5. AllowBrowserDrop
          6. 19.1.2.6. WebBrowserShortcutsEnabled
          7. 19.1.2.7. IsWebBrowserContextMenuEnabled
          8. 19.1.2.8. ScriptErrorsSuppressed
          9. 19.1.2.9. DocumentText
          10. 19.1.2.10. DocumentStream
          11. 19.1.2.11. Document
        3. 19.1.3. WebBrowser Control Methods
          1. 19.1.3.1. Navigate
          2. 19.1.3.2. Go Methods
          3. 19.1.3.3. Stop
          4. 19.1.3.4. Refresh
          5. 19.1.3.5. Show Methods
          6. 19.1.3.6. Print
        4. 19.1.4. WebBrowser Control Events
          1. 19.1.4.1. Navigating
          2. 19.1.4.2. DocumentCompleted
        5. 19.1.5. VB 2010 at Work: The Stock Quotes Project
          1. 19.1.5.1. Obtaining the HTML Widget
          2. 19.1.5.2. Creating the Stock Quotes Project
          3. 19.1.5.3. Displaying the Stock Quotes Badge inside the WebBrowser Control
      2. 19.2. Accessing the Web with the WebClient and HttpWebRequest/Response Classes
        1. 19.2.1. The WebClient Class
        2. 19.2.2. WebClient Class Properties
          1. 19.2.2.1. QueryString
          2. 19.2.2.2. Headers
          3. 19.2.2.3. ResponseHeaders
        3. 19.2.3. WebClient Class Methods
          1. 19.2.3.1. Download Methods
          2. 19.2.3.2. Download*Async Methods
          3. 19.2.3.3. OpenRead and OpenReadAsync Methods
          4. 19.2.3.4. Upload and Upload*Async Methods
          5. 19.2.3.5. CancelAsync Method
        4. 19.2.4. WebClient Class Event
          1. 19.2.4.1. Download*Completed and Upload*Completed events
        5. 19.2.5. WebClient Asynchronous Download Example
        6. 19.2.6. HttpWebRequest and HttpWebResponse Classes
          1. 19.2.6.1. Managing Cookies with HttpWebRequest and HttpWebResponse
      3. 19.3. Putting It All Together: The Address Visualization Form
        1. 19.3.1. Composing Web Services
          1. 19.3.1.1. Yahoo! Geocoding API
          2. 19.3.1.2. Google Maps Service
        2. 19.3.2. Coding Address Visualization Form
          1. 19.3.2.1. Assembling the Address Visualization Form
          2. 19.3.2.2. Constructing the Geocoding Service URL and Query Parameters
          3. 19.3.2.3. Invoking the Yahoo! Geocoding Web Service
          4. 19.3.2.4. Processing the Yahoo! Geocoding Service Response
          5. 19.3.2.5. Displaying Coordinates on the Map
      4. 19.4. The Bottom Line
    2. 20. Building Web Applications
      1. 20.1. Developing for the Web
      2. 20.2. Understanding HTML and XHTML
      3. 20.3. Working with HTML
        1. 20.3.1. Page Construction
        2. 20.3.2. Text Management
        3. 20.3.3. Horizontal Rules
        4. 20.3.4. Images
        5. 20.3.5. Links
        6. 20.3.6. Embedding Media
        7. 20.3.7. Comments
        8. 20.3.8. Scripts
        9. 20.3.9. Lists
        10. 20.3.10. Tables
        11. 20.3.11. Page Formatting
        12. 20.3.12. Forms and Form Elements
      4. 20.4. Cascading Style Sheets (CSS)
        1. 20.4.1. Formatting Styles with CSS
        2. 20.4.2. Page Formatting with CSS
      5. 20.5. JavaScript
        1. 20.5.1. AJAX
      6. 20.6. Microformats
      7. 20.7. Server-Side Technologies
      8. 20.8. Creating a Web Application
      9. 20.9. Controls
        1. 20.9.1. Standard Controls
        2. 20.9.2. Data Controls
        3. 20.9.3. Validation Controls
        4. 20.9.4. Navigation Controls
        5. 20.9.5. Login Controls
        6. 20.9.6. WebParts Controls
        7. 20.9.7. AJAX Extensions Controls
        8. 20.9.8. Reporting Controls
        9. 20.9.9. HTML Controls
      10. 20.10. Maintaining State
      11. 20.11. Master Pages
      12. 20.12. ASP.NET Objects
      13. 20.13. Postback
      14. 20.14. VB 2010 at Work: Online Ordering Application
        1. 20.14.1. Creating the Project
        2. 20.14.2. Creating the Products Web Form
        3. 20.14.3. Creating the Quantity Web Form
          1. 20.14.3.1. Creating the Cart Web Form
      15. 20.15. The Bottom Line
    3. 21. Building and Using Web Services
      1. 21.1. Using ASP.NET and WCF Web Services
        1. 21.1.1. What Is a Service?
        2. 21.1.2. Consuming Web Services
        3. 21.1.3. ASP.NET Web Services
        4. 21.1.4. WCF
      2. 21.2. Understanding Technologies Associated with Web Services
        1. 21.2.1. SOAP
        2. 21.2.2. WSDL
        3. 21.2.3. SOAP Discovery
        4. 21.2.4. UDDI
      3. 21.3. Creating a Simple ASP.NET Web Service
        1. 21.3.1. Setting Up the Web Service
        2. 21.3.2. Testing the Web Service
        3. 21.3.3. Consuming the Web Service
      4. 21.4. Developing a Stand-Alone Web Service
        1. 21.4.1. Building MyWebService
        2. 21.4.2. Deploying MyWebService
        3. 21.4.3. Consuming MyWebService
          1. 21.4.3.1. Adding a Web Reference
          2. 21.4.3.2. Adding the Code-Behind
      5. 21.5. Simple AJAX Implementation
      6. 21.6. Building and Using WCF Services
        1. 21.6.1. Building a WCF Service
          1. 21.6.1.1. Configuring WCF Services
      7. 21.7. ADO.NET Data Services
        1. 21.7.1.
          1. 21.7.1.1. Filtering
          2. 21.7.1.2. The Basic Query Operators
        2. 21.7.2. Building a Windows Client
        3. 21.7.3. Submitting Updates
        4. 21.7.4. Performing Transactions
        5. 21.7.5. Securing Your Data Service
      8. 21.8. The Bottom Line
    4. A. The Bottom Line
      1. A.1. Chapter 1: Getting Started with Visual Basic 2010
      2. A.2. Chapter 2: Handling Data
      3. A.3. Chapter 3: Visual Basic Programming Essentials
      4. A.4. Chapter 4: GUI Design and Event-Driven Programming
      5. A.5. Chapter 5: Basic Windows Controls
      6. A.6. Chapter 6: Working with Forms
      7. A.7. Chapter 7: More Windows Controls
      8. A.8. Chapter 8: Working with Projects
      9. A.9. Chapter 9: Building Custom Windows Controls
      10. A.10. Chapter 10: Applied Object-Oriented Programming
      11. A.11. Chapter 11: The Framework at Large
      12. A.12. Chapter 12: Storing Data in Collections
      13. A.13. Chapter 13: XML in Modern Programming
      14. A.14. Chapter 14: An Introduction to LINQ
      15. A.15. Chapter 15: Programming with ADO.NET
      16. A.16. Chapter 16: Developing Data-Driven Applications
      17. A.17. Chapter 17: Using the Entity Data Model
      18. A.18. Chapter 18: Building Data-Bound Applications
      19. A.19. Chapter 19: Accessing the Web
      20. A.20. Chapter 20: Building Web Applications
      21. A.21. Chapter 21: Building and Using Web Services

Product information

  • Title: Mastering Microsoft® Visual Basic® 2010
  • Author(s):
  • Release date: April 2010
  • Publisher(s): Sybex
  • ISBN: 9780470532874