Mastering Microsoft® Visual Basic® 2008

Book description

This expert guide covers what you need to know to program with Visual Basic 2008, employ the latest Visual Studio 2008 tools, and operate efficiently within the .NET Framework. In an easy-to-follow style, the book moves from in-depth explanations to practical instruction to real-world examples. Explore basic coding in VB 2008 and learn to build interfaces without coding by using Visual Studio 2008's drag-and-drop visual tools. You'll get up to speed on LINQ and handle key tasks such as programming TreeView controls, and more.

Table of contents

  1. Copyright
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. The Mastering Series
    2. Who Should Read This Book?
    3. How about the Advanced Topics?
    4. The Structure of the Book
    5. Downloading This Book's Code
  5. 1. Getting Started with Visual Basic 2008
    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
    3. 1.3. Making the Application More User-Friendly
    4. 1.4. Understanding the IDE Components
      1. 1.4.1. The IDE Menu
        1. 1.4.1.1. File Menu
        2. 1.4.1.2. Edit Menu
        3. 1.4.1.3. View Menu
        4. 1.4.1.4. Project Menu
        5. 1.4.1.5. Build Menu
        6. 1.4.1.6. Debug Menu
        7. 1.4.1.7. Data Menu
        8. 1.4.1.8. Format Menu
        9. 1.4.1.9. Tools Menu
        10. 1.4.1.10. Window Menu
        11. 1.4.1.11. Help Menu
      2. 1.4.2. Toolbox Window
      3. 1.4.3. Solution Explorer Window
      4. 1.4.4. Properties Window
      5. 1.4.5. Output Window
      6. 1.4.6. Command and Immediate Windows
      7. 1.4.7. Error List Window
    5. 1.5. Setting Environment Options
    6. 1.6. Building a Console Application
    7. 1.7. Using Code Snippets
    8. 1.8. Using the My Object
    9. 1.9. The Bottom Line
  6. 2. Variables and Data Types
    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
        3. 2.1.1.3. Type Inference
      2. 2.1.2. Types of Variables
        1. 2.1.2.1. Numeric Variables
        2. 2.1.2.2. Infinity and Other Oddities
        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
        8. 2.1.2.8. Data Type Identifiers
      3. 2.1.3. The Strict, Explicit, and Infer Options
    2. 2.2. Object Variables
    3. 2.3. Variables as Objects
      1. 2.3.1. Converting Variable Types
        1. 2.3.1.1. Widening and Narrowing Conversions
      2. 2.3.2. Formatting Numbers
        1. 2.3.2.1. Standard Numeric Format Strings
        2. 2.3.2.2. Picture Numeric Format Strings
      3. 2.3.3. User-Defined Data Types
        1. 2.3.3.1. The Nothing Value
      4. 2.3.4. Examining Variable Types
        1. 2.3.4.1. Is It A Number, String, Or Date?
      5. 2.3.5. Why Declare Variables?
      6. 2.3.6. A Variable's Scope
      7. 2.3.7. A Variable's Lifetime
    4. 2.4. Constants
    5. 2.5. Arrays
      1. 2.5.1. Declaring Arrays
      2. 2.5.2. Initializing Arrays
      3. 2.5.3. Array Limits
      4. 2.5.4. Multidimensional Arrays
      5. 2.5.5. Dynamic Arrays
        1. 2.5.5.1. The Preserve Keyword
    6. 2.6. The Bottom Line
  7. 3. Programming Fundamentals
    1. 3.1. Flow-Control Statements
      1. 3.1.1. Decision Statements
        1. 3.1.1.1. If...Then
        2. 3.1.1.2. If...Then...Else
        3. 3.1.1.3. Select Case
        4. 3.1.1.4. Short-Circuiting Expression Evaluation
      2. 3.1.2. Loop Statements
        1. 3.1.2.1. For...Next
        2. 3.1.2.2. Do...Loop
        3. 3.1.2.3. While...End While
      3. 3.1.3. Nested Control Structures
      4. 3.1.4. The Exit Statement
    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
        3. 3.3.1.3. Passing Objects as Arguments
      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
      5. 3.3.5. More Types of Function Return Values
        1. 3.3.5.1. Functions Returning Structures
        2. 3.3.5.2. VB 2008 at Work: The Types Project
        3. 3.3.5.3. Functions Returning Arrays
        4. 3.3.5.4. VB 2008 at Work: The Statistics Project
      6. 3.3.6. Overloading Functions
    4. 3.4. The Bottom Line
  8. 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 Simple Debugging Tools
      4. 4.3.4. Exception Handling
    4. 4.4. The Bottom Line
  9. 5. The Vista Interface
    1. 5.1. Introducing XAML
    2. 5.2. Introducing the WPF Controls
      1. 5.2.1. Simple "Hello World" WPF Application
      2. 5.2.2. Simple Drawing Program
    3. 5.3. Data-Binding WPF Controls
      1. 5.3.1. Data-Binding Example 1: Binding to an Array and a Data Template
      2. 5.3.2. Data-Binding Example 2: Binding to a Database
    4. 5.4. Creating a WPF Browser Application
    5. 5.5. Expression Blend Overview
    6. 5.6. The Bottom Line
  10. 6. Basic Windows Controls
    1. 6.1. The TextBox Control
      1. 6.1.1. Basic Properties
        1. 6.1.1.1. TextAlign
        2. 6.1.1.2. MultiLine
        3. 6.1.1.3. MaxLength
        4. 6.1.1.4. ScrollBars
        5. 6.1.1.5. WordWrap
        6. 6.1.1.6. AcceptsReturn, AcceptsTab
        7. 6.1.1.7. CharacterCasing
        8. 6.1.1.8. PasswordChar
        9. 6.1.1.9. ReadOnly, Locked
      2. 6.1.2. Text-Manipulation Properties
        1. 6.1.2.1. Text
        2. 6.1.2.2. Lines
      3. 6.1.3. Text-Selection Properties
        1. 6.1.3.1. SelectedText
        2. 6.1.3.2. SelectionStart, SelectionLength
        3. 6.1.3.3. HideSelection
      4. 6.1.4. Text-Selection Methods
      5. 6.1.5. Undoing Edits
      6. 6.1.6. VB 2008 at Work: The TextPad Project
        1. 6.1.6.1. The Editing Commands
        2. 6.1.6.2. The Process and Format Menus
        3. 6.1.6.3. Search and Replace Operations
        4. 6.1.6.4. The Undo/Redo Commands
      7. 6.1.7. Capturing Keystrokes
        1. 6.1.7.1. Capturing Function Keys
      8. 6.1.8. Auto-complete Properties
    2. 6.2. The ListBox, CheckedListBox, and ComboBox Controls
      1. 6.2.1. Basic Properties
        1. 6.2.1.1. IntegralHeight
        2. 6.2.1.2. Items
        3. 6.2.1.3. MultiColumn
        4. 6.2.1.4. SelectionMode
        5. 6.2.1.5. Sorted
        6. 6.2.1.6. Text
      2. 6.2.2. Manipulating the Items Collection
        1. 6.2.2.1. The Add Method
        2. 6.2.2.2. The Insert Method
        3. 6.2.2.3. The Clear Method
        4. 6.2.2.4. The Count Property
        5. 6.2.2.5. The Copyto Method
        6. 6.2.2.6. The Remove and RemoveAt Methods
        7. 6.2.2.7. The Contains Method
      3. 6.2.3. Selecting Items
      4. 6.2.4. VB 2008 at Work: The ListBox Demo Project
        1. 6.2.4.1. The Add Item Buttons
        2. 6.2.4.2. Removing Items from the Two Lists
        3. 6.2.4.3. Moving Items between Lists
      5. 6.2.5. Searching the ListBox
        1. 6.2.5.1. VB 2008 at Work: The ListBoxFind Application
      6. 6.2.6. The ComboBox Control
        1. 6.2.6.1. Adding Items to a ComboBox at Runtime
        2. 6.2.6.2. VB 2008 At Work: The FlexCombo Project
    3. 6.3. The ScrollBar and TrackBar Controls
      1. 6.3.1. The ScrollBar Control
        1. 6.3.1.1. VB 2008 At Work: The Colors Project
        2. 6.3.1.2. The ScrollBar Control'S Events
        3. 6.3.1.3. Handling the Events in the Colors Application
      2. 6.3.2. The TrackBar Control
        1. 6.3.2.1. VB 2008 at Work: The Inches Project
    4. 6.4. The Bottom Line
  11. 7. Working with Forms
    1. 7.1. The Appearance of Forms
      1. 7.1.1. Properties of the Form Object
        1. 7.1.1.1. AcceptButton, CancelButton
        2. 7.1.1.2. AutoScaleMode
        3. 7.1.1.3. AutoScroll
        4. 7.1.1.4. AutoScrollPosition
        5. 7.1.1.5. AutoScrollMargin
        6. 7.1.1.6. AutoScrollMinSize
        7. 7.1.1.7. FormBorderStyle
        8. 7.1.1.8. ControlBox
        9. 7.1.1.9. MinimizeBox, MaximizeBox
        10. 7.1.1.10. MinimumSize, MaximumSize
        11. 7.1.1.11. KeyPreview
        12. 7.1.1.12. SizeGripStyle
        13. 7.1.1.13. StartPosition, Location
        14. 7.1.1.14. TopMost
        15. 7.1.1.15. Size
      2. 7.1.2. Placing Controls on Forms
      3. 7.1.3. Setting the TabOrder Property
      4. 7.1.4. VB 2008 at Work: The Contacts Project
        1. 7.1.4.1. Handling Keystrokes
      5. 7.1.5. Anchoring and Docking
        1. 7.1.5.1. Anchoring Controls
        2. 7.1.5.2. Docking Controls
      6. 7.1.6. Splitting Forms into Multiple Panes
      7. 7.1.7. The Form's Events
        1. 7.1.7.1. The Activated and Deactivate Events
        2. 7.1.7.2. The FormClosing and FormClosed Events
        3. 7.1.7.3. The Resize, ResizeBegin, and ResizeEnd Events
        4. 7.1.7.4. The Scroll Event
        5. 7.1.7.5. The Paint Event
    2. 7.2. Loading and Showing Forms
      1. 7.2.1. The Startup Form
      2. 7.2.2. Controlling One Form from within Another
        1. 7.2.2.1. Sharing Variables between Forms
      3. 7.2.3. Forms versus Dialog Boxes
        1. 7.2.3.1. VB 2008 at Work: The MultipleForms Project
    3. 7.3. Building Dynamic Forms at Runtime
      1. 7.3.1. The Form's Controls Collection
        1. 7.3.1.1. VB 2008 at Work: The ShowControls Project
        2. 7.3.1.2. VB 2008 at Work: The DynamicForm Project
      2. 7.3.2. Creating Event Handlers at Runtime
    4. 7.4. Designing Menus
      1. 7.4.1. The Menu Editor
      2. 7.4.2. The ToolStripMenuItem Properties
        1. 7.4.2.1. Programming Menu Commands
        2. 7.4.2.2. Using Access and Shortcut Keys
      3. 7.4.3. Manipulating Menus at Runtime
        1. 7.4.3.1. Creating Short and Long Menus
        2. 7.4.3.2. Adding and Removing Commands at Runtime
        3. 7.4.3.3. Creating Context Menus
      4. 7.4.4. Iterating a Menu's Items
        1. 7.4.4.1. VB 2008 at Work: The MapMenu Project
    5. 7.5. The Bottom Line
  12. 8. More Windows Controls
    1. 8.1. The Common Dialog Controls
      1. 8.1.1. Using the Common Dialog Controls
      2. 8.1.2. The ColorDialog Control
        1. 8.1.2.1. AllowFullOpen
        2. 8.1.2.2. AnyColor
        3. 8.1.2.3. Color
        4. 8.1.2.4. CustomColors
        5. 8.1.2.5. SolidColorOnly
      3. 8.1.3. The FontDialog Control
        1. 8.1.3.1. AllowScriptChange
        2. 8.1.3.2. AllowVerticalFonts
        3. 8.1.3.3. Color, ShowColor
        4. 8.1.3.4. FixedPitchOnly
        5. 8.1.3.5. Font
        6. 8.1.3.6. FontMustExist
        7. 8.1.3.7. MaxSize, MinSize
        8. 8.1.3.8. ShowApply
        9. 8.1.3.9. ShowEffects
      4. 8.1.4. The OpenDialog and SaveDialog Controls
        1. 8.1.4.1. AddExtension
        2. 8.1.4.2. CheckFileExists
        3. 8.1.4.3. CheckPathExists
        4. 8.1.4.4. DefaultExt
        5. 8.1.4.5. DereferenceLinks
        6. 8.1.4.6. FileName
        7. 8.1.4.7. Filter
        8. 8.1.4.8. FilterIndex
        9. 8.1.4.9. InitialDirectory
        10. 8.1.4.10. RestoreDirectory
        11. 8.1.4.11. FileNames
        12. 8.1.4.12. MultiSelect
        13. 8.1.4.13. ReadOnlyChecked, ShowReadOnly
        14. 8.1.4.14. The OpenFile and SaveFile Methods
        15. 8.1.4.15. VB 2008 at Work: Multiple File Selection
      5. 8.1.5. The FolderBrowserDialog Control
        1. 8.1.5.1. RootFolder
        2. 8.1.5.2. SelectedFolder
        3. 8.1.5.3. ShowNewFolderButton
        4. 8.1.5.4. VB 2008 at Work: Folder Browsing Demo Project
    2. 8.2. The RichTextBox Control
      1. 8.2.1. The RTF Language
      2. 8.2.2. Text Manipulation and Formatting Properties
        1. 8.2.2.1. SelectedText
        2. 8.2.2.2. SelectionStart, SelectionLength
        3. 8.2.2.3. SelectionAlignment
        4. 8.2.2.4. SelectionIndent, SelectionRightIndent, SelectionHangingIndent
        5. 8.2.2.5. SelectionBullet, BulletIndent
        6. 8.2.2.6. SelectionTabs
      3. 8.2.3. Methods
        1. 8.2.3.1. SaveFile
        2. 8.2.3.2. LoadFile
        3. 8.2.3.3. Select, SelectAll
      4. 8.2.4. Advanced Editing Features
        1. 8.2.4.1. CanUndo, CanRedo
        2. 8.2.4.2. UndoActionName, RedoActionName
        3. 8.2.4.3. Undo, Redo
      5. 8.2.5. Cutting and Pasting
      6. 8.2.6. Searching in a RichTextBox Control
      7. 8.2.7. Handling URLs in the Document
      8. 8.2.8. Displaying a Formatted Directory Listing
      9. 8.2.9. VB 2008 at Work: The RTFPad Project
        1. 8.2.9.1. The File Menu
        2. 8.2.9.2. The Edit Menu
        3. 8.2.9.3. The Format Menu
        4. 8.2.9.4. The Search & Replace Dialog Box
    3. 8.3. The Bottom Line
  13. 9. The TreeView and ListView Controls
    1. 9.1. Understanding the ListView, TreeView, and ImageList Controls
      1. 9.1.1. Tree and List Structures
      2. 9.1.2. The ImageList Control
    2. 9.2. The TreeView Control
      1. 9.2.1. Adding Nodes at Design Time
      2. 9.2.2. Adding Nodes at Runtime
        1. 9.2.2.1. Adding New Nodes
        2. 9.2.2.2. The Nodes Collection Members
        3. 9.2.2.3. Basic Nodes Properties
      3. 9.2.3. VB 2008 at Work: The TreeViewDemo Project
        1. 9.2.3.1. Inserting a Root Node
        2. 9.2.3.2. Enumerating the Nodes Collection
      4. 9.2.4. VB 2008 at Work: The Globe Project
        1. 9.2.4.1. Adding New Nodes
        2. 9.2.4.2. Retrieving the Selected Node
        3. 9.2.4.3. Processing Multiple Selected Nodes
        4. 9.2.4.4. Adding New Nodes
        5. 9.2.4.5. Listing Continents/Countries/Cities
      5. 9.2.5. Scanning the TreeView Control
        1. 9.2.5.1. VB 2008 at Work: The TreeViewScan Project
    3. 9.3. The ListView Control
      1. 9.3.1. The Columns Collection
        1. 9.3.1.1. Adding and Removing Columns at Runtime
      2. 9.3.2. ListView Items and Subitems
      3. 9.3.3. The Items Collection
      4. 9.3.4. The SubItems Collection
      5. 9.3.5. VB 2008 at Work: The ListViewDemo Project
        1. 9.3.5.1. Enumerating the List
      6. 9.3.6. Sorting the ListView Control
      7. 9.3.7. Processing Selected Items
      8. 9.3.8. VB 2008 at Work: The CustomExplorer Project
        1. 9.3.8.1. Viewing a Folder'S Files
      9. 9.3.9. Additional Topics
    4. 9.4. The Bottom Line
  14. 10. Building Custom Classes
    1. 10.1. Classes and Objects
    2. 10.2. What Is a Class?
      1. 10.2.1. Classes Combine Code with Data
    3. 10.3. Building the Minimal Class
      1. 10.3.1. Adding Code to the Minimal Class
      2. 10.3.2. Using Property Procedures
        1. 10.3.2.1. Throwing Exceptions
        2. 10.3.2.2. Implementing Read-Only Properties
      3. 10.3.3. Customizing Default Members
        1. 10.3.3.1. Customizing the ToString Method
        2. 10.3.3.2. Customizing the Equals Method
        3. 10.3.3.3. Know What You Are Comparing
        4. 10.3.3.4. The Is Operator
      4. 10.3.4. Custom Enumerations
        1. 10.3.4.1. VB 2008 at Work: The Contacts Project
      5. 10.3.5. Object Constructors
      6. 10.3.6. Using the SimpleClass in Other Projects
      7. 10.3.7. Firing Events
      8. 10.3.8. Instance and Shared Methods
    4. 10.4. A "Real" Class
      1. 10.4.1. Parsing a Filename
      2. 10.4.2. Converting Numbers to Strings
    5. 10.5. Operator Overloading
      1. 10.5.1. VB 2008 at Work: The LengthUnits Class
        1. 10.5.1.1. Implementing Unary Operators
        2. 10.5.1.2. Handling Variants
    6. 10.6. The Bottom Line
  15. 11. Working with Objects
    1. 11.1. Issues in Object-Oriented Programming
      1. 11.1.1. Classes versus Objects
      2. 11.1.2. Objects versus Object Variables
        1. 11.1.2.1. Exploring Value Types
        2. 11.1.2.2. Exploring Reference Types
      3. 11.1.3. Properties versus Fields
      4. 11.1.4. Shared versus Instance Members
      5. 11.1.5. Type Casting
      6. 11.1.6. Early versus Late Binding
      7. 11.1.7. Discovering a Variable's Type
      8. 11.1.8. Inheritance
      9. 11.1.9. How to Apply Inheritance
        1. 11.1.9.1. Inheriting Existing Classes
        2. 11.1.9.2. Inheriting Custom Classes
      10. 11.1.10. Polymorphism
      11. 11.1.11. Building the Shape Class
        1. 11.1.11.1. Testing the Shape Class
    2. 11.2. Who Can Inherit What?
      1. 11.2.1. Parent Class Keywords
      2. 11.2.2. Derived Class Keywords
      3. 11.2.3. Parent Class Member Keywords
      4. 11.2.4. Derived Class Member Keyword
      5. 11.2.5. VB 2008 At Work: The InheritanceKeywords Project
      6. 11.2.6. MyBase and MyClass
      7. 11.2.7. The Class Diagram Designer
    3. 11.3. The Bottom Line
  16. 12. Building Custom Windows Controls
    1. 12.1. On Designing Windows Controls
    2. 12.2. Enhancing Existing Controls
      1. 12.2.1. Building the FocusedTextBox Control
        1. 12.2.1.1. Adding Functionality to Your Custom Control
        2. 12.2.1.2. Testing The FocusedTextBox Control
        3. 12.2.1.3. Classifying the Control'S Properties
    3. 12.3. Building Compound Controls
      1. 12.3.1. VB 2008 at Work: The ColorEdit Control
        1. 12.3.1.1. Testing the ColorEdit Control
    4. 12.4. Building User-Drawn Controls
      1. 12.4.1. VB 2008 at Work: The Label3D Control
        1. 12.4.1.1. Label3D Control Specifications
        2. 12.4.1.2. Designing the Custom Control
        3. 12.4.1.3. Testing Your New Control
        4. 12.4.1.4. Changed Events
      2. 12.4.2. Raising Custom Events
      3. 12.4.3. Using the Custom Control in Other Projects
    5. 12.5. Designing Irregularly Shaped Controls
    6. 12.6. Customizing List Controls
      1. 12.6.1. Designing Owner-Drawn ListBox Controls
    7. 12.7. The Bottom Line
  17. 13. Handling Strings, Characters, and Dates
    1. 13.1. Handling Strings and Characters
      1. 13.1.1. The Char Class
        1. 13.1.1.1. Properties
        2. 13.1.1.2. Methods
      2. 13.1.2. The String Class
        1. 13.1.2.1. Properties
        2. 13.1.2.2. Methods
      3. 13.1.3. The StringBuilder Class
        1. 13.1.3.1. Properties
        2. 13.1.3.2. Methods
      4. 13.1.4. VB 2008 at Work: The StringReversal Project
      5. 13.1.5. VB 2008 at Work: The CountWords Project
    2. 13.2. Handling Dates and Times
      1. 13.2.1. The DateTime Class
        1. 13.2.1.1. Properties
        2. 13.2.1.2. Methods
        3. 13.2.1.3. Date Conversion Methods
        4. 13.2.1.4. Dates as Numeric Values
      2. 13.2.2. The TimeSpan Class
        1. 13.2.2.1. Properties
        2. 13.2.2.2. Methods
    3. 13.3. The Bottom Line
  18. 14. Storing Data in Collections
    1. 14.1. AdvancedArray Topics
      1. 14.1.1. Sorting Arrays
      2. 14.1.2. Searching Arrays
        1. 14.1.2.1. VB2008 at Work: The ArraySearch Application
        2. 14.1.2.2. The Binary Search Algorithm
      3. 14.1.3. Performing Other Array Operations
      4. 14.1.4. Array Limitations
    2. 14.2. The ArrayList Collection
      1. 14.2.1. Creating an ArrayList
      2. 14.2.2. Adding and Removing ArrayList Items
        1. 14.2.2.1. Extracting Items From an ArrayList
      3. 14.2.3. Sorting ArrayLists
      4. 14.2.4. Searching ArrayLists
      5. 14.2.5. Iterating an ArrayList
    3. 14.3. The HashTable Collection
      1. 14.3.1. VB 2008 at Work: The WordFrequencies Project
    4. 14.4. The SortedList Collection
      1. 14.4.1. VB 2008 at Work: The SortedList Project
        1. 14.4.1.1. Working with Keys and Values
    5. 14.5. Other Collections
    6. 14.6. The IEnumerator and IComparer Interfaces
      1. 14.6.1. Enumerating Collections
      2. 14.6.2. Custom Sorting
        1. 14.6.2.1. Implementing the Icomparer Interface
        2. 14.6.2.2. Implementing Multiple Comparers
        3. 14.6.2.3. Custom Sorting of a SortedList
    7. 14.7. Generic Collections
    8. 14.8. The Bottom Line
  19. 15. Accessing Folders and Files
    1. 15.1. The IO Namespace and the FileSystem Component
    2. 15.2. Using the My.Computer.FileSystem Component
    3. 15.3. Manipulating Folders and Fileswith the IO Namespace
      1. 15.3.1. The Directory Class
        1. 15.3.1.1. Methods
      2. 15.3.2. The File Class
        1. 15.3.2.1. Methods
      3. 15.3.3. Drive, Folder, and File Properties
        1. 15.3.3.1. The DriveInfo Class
        2. 15.3.3.2. The DirectoryInfo Class
        3. 15.3.3.3. The FileInfo Class
      4. 15.3.4. The Path Class
        1. 15.3.4.1. Properties
        2. 15.3.4.2. Methods
      5. 15.3.5. VB 2008 at Work: The CustomExplorer Project
    4. 15.4. Accessing Files
      1. 15.4.1. Using Streams
        1. 15.4.1.1. The FileStream Class
        2. 15.4.1.2. The StreamWriter Class
        3. 15.4.1.3. The StreamReader Class
        4. 15.4.1.4. Sending Data to a File
        5. 15.4.1.5. The BinaryWriter Class
        6. 15.4.1.6. The BinaryReader Class
      2. 15.4.2. VB 2008 at Work: The RecordSave Project
    5. 15.5. The FileSystemWatcher Component
      1. 15.5.1. Properties
        1. 15.5.1.1. NotifyFilter
        2. 15.5.1.2. Path, IncludeSubdirectories
        3. 15.5.1.3. Filter
        4. 15.5.1.4. EnableRaisingEvents
      2. 15.5.2. Events
      3. 15.5.3. VB 2008 at Work: The FileSystemWatcher Project
    6. 15.6. The Bottom Line
  20. 16. Serialization and XML
    1. 16.1. Understanding Serialization Types
    2. 16.2. Using Binary and SOAP Serialization
      1. 16.2.1. Serializing Individual Objects
      2. 16.2.2. Deserializing Individual Objects
      3. 16.2.3. Serializing Collections
      4. 16.2.4. Deserializing Collections
    3. 16.3. Persisting a HashTable
    4. 16.4. Persisting a TreeView's Nodes
    5. 16.5. Using XML Serialization
      1. 16.5.1. Serializing and Deserializing Individual Objects
      2. 16.5.2. Serializing Custom Objects
      3. 16.5.3. Serializing ArrayLists and HashTables
    6. 16.6. Working with XML Files
      1. 16.6.1. Understanding XML Structure
      2. 16.6.2. Editing XML Files
    7. 16.7. The Bottom Line
  21. 17. Querying Collections and XML with LINQ
    1. 17.1. What Is LINQ?
      1. 17.1.1. LINQ Components
    2. 17.2. LINQ to Objects
      1. 17.2.1. Querying Collections
      2. 17.2.2. Aggregating with LINQ
    3. 17.3. LINQ to XML
      1. 17.3.1. Traversing XML Documents
      2. 17.3.2. Adding Dynamic Content to an XML Document
        1. 17.3.2.1. Transforming XML Documents
        2. 17.3.2.2. Working with XML Files
    4. 17.4. LINQ to SQL
      1. 17.4.1. Retrieving Data with the ExecuteQuery Method
    5. 17.5. The Bottom Line
  22. 18. Drawing and Painting with Visual Basic 2008
    1. 18.1. Displaying and Sizing Images
    2. 18.2. Drawing with GDI+
      1. 18.2.1. The Basic Drawing Objects
        1. 18.2.1.1. The Graphics Object
        2. 18.2.1.2. The Point Class
        3. 18.2.1.3. The Rectangle Class
        4. 18.2.1.4. The Size Class
        5. 18.2.1.5. The Color Class
        6. 18.2.1.6. The Font Class
        7. 18.2.1.7. The Pen Class
        8. 18.2.1.8. The Brush Class
        9. 18.2.1.9. The Path Class
      2. 18.2.2. Drawing Shapes
        1. 18.2.2.1. Persistent Drawing
      3. 18.2.3. Drawing Methods
        1. 18.2.3.1. DrawLine
        2. 18.2.3.2. DrawRectangle
        3. 18.2.3.3. DrawEllipse
        4. 18.2.3.4. DrawPie
        5. 18.2.3.5. DrawPolygon
        6. 18.2.3.6. DrawCurve
        7. 18.2.3.7. DrawBezier
        8. 18.2.3.8. DrawPath
        9. 18.2.3.9. DrawString, MeasureString
        10. 18.2.3.10. DrawImage
      4. 18.2.4. Gradients
        1. 18.2.4.1. Linear Gradients
        2. 18.2.4.2. Path Gradients
      5. 18.2.5. Clipping
    3. 18.3. Applying Transformations
      1. 18.3.1. VB 2008 at Work: The ImageCube Project
      2. 18.3.2. VB 2008 at Work: Plotting Functions
    4. 18.4. The Bottom Line
  23. 19. Manipulating Images and Bitmaps
    1. 19.1. Specifying Colors
      1. 19.1.1. The RGB Color Cube
      2. 19.1.2. Defining Colors
        1. 19.1.2.1. Alpha Blending
    2. 19.2. The Image Object
      1. 19.2.1. Properties
        1. 19.2.1.1. HorizontalResolution, VerticalResolution
        2. 19.2.1.2. Width, Height
        3. 19.2.1.3. PixelFormat
      2. 19.2.2. Methods
        1. 19.2.2.1. RotateFlip
        2. 19.2.2.2. Get Thumbnail Image
        3. 19.2.2.3. Save
      3. 19.2.3. VB 2008 at Work: The Thumbnails Project
      4. 19.2.4. Exchanging Images through the Clipboard
    3. 19.3. The Bitmap Object
      1. 19.3.1. Processing Bitmaps
      2. 19.3.2. VB 2008 at Work: The ImageProcessing Project
        1. 19.3.2.1. How the Application Works
        2. 19.3.2.2. Applying Effects
    4. 19.4. The Bottom Line
  24. 20. Printing with Visual Basic 2008
    1. 20.1. The Printing Components
      1. 20.1.1. The PrintDocument Control
      2. 20.1.2. The PrintDialog Control
      3. 20.1.3. The PageSetupDialog Control
      4. 20.1.4. The PrintPreviewDialog Control
    2. 20.2. Printer and Page Properties
      1. 20.2.1. Retrieving the Printer Names
      2. 20.2.2. Page Geometry
      3. 20.2.3. VB 2008 at Work: The SimplePrintout Project
      4. 20.2.4. VB 2008 at Work: The PageSettings Project
        1. 20.2.4.1. Setting up the Page
        2. 20.2.4.2. Printing the Labels
    3. 20.3. Practical Printing Examples
      1. 20.3.1. Printing Tabular Data
        1. 20.3.1.1. Formatting the Cells
      2. 20.3.2. Printing Plain Text
        1. 20.3.2.1. VB 2008 at Work: The PrintText Project
      3. 20.3.3. Printing Bitmaps
    4. 20.4. The Bottom Line
  25. 21. Basic Concepts of Relational Databases
    1. 21.1. What Is a Database?
      1. 21.1.1. Using Relational Databases
      2. 21.1.2. Obtaining the Northwind and Pubs Sample Databases
      3. 21.1.3. Exploring the Northwind Database
        1. 21.1.3.1. Products Table
        2. 21.1.3.2. Suppliers Table
        3. 21.1.3.3. Categories Table
        4. 21.1.3.4. Customers Table
        5. 21.1.3.5. Orders Table
        6. 21.1.3.6. Order Details Table
        7. 21.1.3.7. Employees Table
        8. 21.1.3.8. Shippers Table
      4. 21.1.4. Exploring the Pubs Database
        1. 21.1.4.1. Titles Table
        2. 21.1.4.2. Authors Table
        3. 21.1.4.3. TitleAuthor Table
        4. 21.1.4.4. Publishers Table
      5. 21.1.5. Understanding Relations
        1. 21.1.5.1. Referential Integrity
        2. 21.1.5.2. Visual Database Tools
    2. 21.2. Server Explorer
      1. 21.2.1. Working with Tables
        1. 21.2.1.1. Show Table Data
        2. 21.2.1.2. Open Table Definition
        3. 21.2.1.3. Add New Table
      2. 21.2.2. Working with Relationships, Indices, and Constraints
        1. 21.2.2.1. Relationships
        2. 21.2.2.2. Indices/Keys
        3. 21.2.2.3. Check Constraints
    3. 21.3. Structured Query Language
      1. 21.3.1. Executing SQL Statements
        1. 21.3.1.1. Using the Sql Server Management Studio (Ssms)
        2. 21.3.1.2. Using Visual Studio
      2. 21.3.2. Using Selection Queries
        1. 21.3.2.1. Limiting the Selection with Where
        2. 21.3.2.2. Selecting Columns from Multiple Tables
        3. 21.3.2.3. Aliasing Table Names
        4. 21.3.2.4. Aliasing Column Names with AS
        5. 21.3.2.5. Skipping Duplicates with DISTINCT
        6. 21.3.2.6. The LIKE Operator
        7. 21.3.2.7. Null Values and the ISNULL Function
        8. 21.3.2.8. Sorting the Rows with ORDER BY
        9. 21.3.2.9. Limiting the Number of Rows with TOP
      3. 21.3.3. Working with Calculated Fields
      4. 21.3.4. Calculating Aggregates
      5. 21.3.5. Using SQL Joins
        1. 21.3.5.1. Left Joins
        2. 21.3.5.2. Right Joins
        3. 21.3.5.3. Full Joins
        4. 21.3.5.4. Inner Joins
      6. 21.3.6. Grouping Rows
      7. 21.3.7. Limiting Groups with HAVING
      8. 21.3.8. Selecting Groups with IN and NOT IN
      9. 21.3.9. Selecting Ranges with BETWEEN
    4. 21.4. Action Queries
      1. 21.4.1. Deleting Rows
      2. 21.4.2. Inserting New Rows
      3. 21.4.3. Editing Existing Rows
    5. 21.5. TheQuery Builder
      1. 21.5.1. The Query Builder Interface
        1. 21.5.1.1. Diagram Pane
        2. 21.5.1.2. Criteria Pane
        3. 21.5.1.3. SQL Pane
        4. 21.5.1.4. Results Pane
      2. 21.5.2. SQL at Work: Calculating Sums
      3. 21.5.3. SQL at Work: Counting Rows
      4. 21.5.4. Parameterized Queries
      5. 21.5.5. Calculated Columns
    6. 21.6. Stored Procedures
      1. 21.6.1. The SalesByCategory Stored Procedure
    7. 21.7. The Bottom Line
  26. 22. Programming with ADO.NET
    1. 22.1. Stream- versus Set-Based Data Access
    2. 22.2. The Basic Data-Access Classes
      1. 22.2.1. The Connection Class
      2. 22.2.2. The Command Class
        1. 22.2.2.1. Executing Stored Procedures
        2. 22.2.2.2. Executing Selection Queries
        3. 22.2.2.3. Using Commands with Parameters
        4. 22.2.2.4. Retrieving Multiple Values from a Stored Procedure
        5. 22.2.2.5. Handling Special Characters
        6. 22.2.2.6. Empty Strings Versus Null Values
      3. 22.2.3. The DataReader Class
        1. 22.2.3.1. Reading Multiple Result Sets
    3. 22.3. Storing Data in DataSets
      1. 22.3.1. Filling DataSets
        1. 22.3.1.1. The DataAdapter Class
        2. 22.3.1.2. The CommandBuilder Class
      2. 22.3.2. Accessing the DataSet's Tables
      3. 22.3.3. Working with Rows
      4. 22.3.4. Handling Null Values
      5. 22.3.5. Adding and Deleting Rows
      6. 22.3.6. Navigating through a DataSet
        1. 22.3.6.1. Row States and Versions
    4. 22.4. Update Operations
      1. 22.4.1. Updating the Database with the DataAdapter
      2. 22.4.2. Handling Identity Columns
    5. 22.5. VB2008 at Work: The SimpleDataSet Project
    6. 22.6. The Bottom Line
  27. 23. Building Data-Bound Applications
    1. 23.1. Working with Typed DataSets
      1. 23.1.1. Generating a Typed DataSet
      2. 23.1.2. Exploring the Typed DataSet
    2. 23.2. Data Binding
      1. 23.2.1. Using the BindingSource Class
        1. 23.2.1.1. Handling Identity Columns
        2. 23.2.1.2. Adjusting the DataSet
    3. 23.3. Designing Data-Driven Interfaces the Easy Way
      1. 23.3.1. Enhancing the Navigational Tools
      2. 23.3.2. Binding Hierarchical Tables
        1. 23.3.2.1. Using the BindingSource as a Data Source
      3. 23.3.3. Adjusting the Appearance of the DataGridView Control
        1. 23.3.3.1. Displaying Lookup Columns in a DataGridView Control
      4. 23.3.4. Building More-Functional Interfaces
        1. 23.3.4.1. Viewing the Deleted Rows
    4. 23.4. The Bottom Line
  28. 24. Advanced DataSet Operations
    1. 24.1. Working with SQL Expressions
      1. 24.1.1. Selecting Rows
    2. 24.2. Simple Calculated Columns
      1. 24.2.1. Calculated Columns with Aggregates
        1. 24.2.1.1. Computing Expressions
    3. 24.3. VB2008 at Work: The SQL Expressions Project
      1. 24.3.1. Selecting and Viewing an Order's Details
        1. 24.3.1.1. Aggregate Functions' Return Values
    4. 24.4. The Bottom Line
  29. 25. Building Web Applications
    1. 25.1. Developing for theWeb
    2. 25.2. Understanding HTML and XHTML
    3. 25.3. Working with HTML
      1. 25.3.1. Page Construction
      2. 25.3.2. Text Management
      3. 25.3.3. Horizontal Rules
      4. 25.3.4. Images
      5. 25.3.5. Links
      6. 25.3.6. Embedding Media
      7. 25.3.7. Comments
      8. 25.3.8. Scripts
      9. 25.3.9. Lists
      10. 25.3.10. Tables
      11. 25.3.11. Page Formatting
      12. 25.3.12. Forms and Form Elements
    4. 25.4. Cascading Style Sheets (CSS)
      1. 25.4.1. Formatting Styles with CSS
      2. 25.4.2. Page Formatting with CSS
    5. 25.5. JavaScript
      1. 25.5.1. AJAX
    6. 25.6. Microformats
    7. 25.7. Server-Side Technologies
    8. 25.8. Creating a Web Application
    9. 25.9. Controls
      1. 25.9.1. Standard Controls
      2. 25.9.2. Data Controls
      3. 25.9.3. Validation Controls
      4. 25.9.4. Navigation Controls
      5. 25.9.5. Login Controls
      6. 25.9.6. WebParts Controls
      7. 25.9.7. AJAX Extensions Controls
      8. 25.9.8. Reporting Controls
      9. 25.9.9. HTML Controls
    10. 25.10. Maintaining State
    11. 25.11. Master Pages
    12. 25.12. ASP.NET Objects
      1. 25.12.1. Application Object
      2. 25.12.2. Context Object
      3. 25.12.3. Request Object
      4. 25.12.4. Response Object
      5. 25.12.5. Server Object
      6. 25.12.6. Session Object
      7. 25.12.7. Trace Object
    13. 25.13. Postback
    14. 25.14. The Bottom Line
  30. 26. ASP.NET 3.5
    1. 26.1. Planning the Demonstration Site
      1. 26.1.1. Getting Started
    2. 26.2. Building the Style Sheet for MasterPage.master
      1. 26.2.1. Creating the Style Sheet
      2. 26.2.2. Attaching the Style Sheet to the Master Page
    3. 26.3. Creating the Content Master Page
      1. 26.3.1. Creating ContentStyleSheet.css
      2. 26.3.2. Completing ContentMasterPage.master
    4. 26.4. Adding Elements to theMainMaster Page
      1. 26.4.1. Creating the Web User Control
      2. 26.4.2. Adding the Web User Control to Your Page
      3. 26.4.3. Creating the Footer.ascx Web User Control
    5. 26.5. Building the SiteNavigation
      1. 26.5.1. Creating a SiteMap
      2. 26.5.2. Configuring the Menu Control for MasterPage.master
      3. 26.5.3. Creating the Navbar in ContentsMasterPage.master
    6. 26.6. Adding Authentication
      1. 26.6.1. Using the Login Control
      2. 26.6.2. Establishing Forms-Based Authentication
      3. 26.6.3. Adding an Access Rule
      4. 26.6.4. Adding a LoginName Control to MasterPage.master
      5. 26.6.5. Adding a LoginName Control to ContentMasterPage.master
    7. 26.7. Adding Content Pages
      1. 26.7.1. Adding an Entry to the SiteMap
      2. 26.7.2. Updating the SiteMapDataSource Control
      3. 26.7.3. Running the Application
    8. 26.8. Adding Further Content Pages
      1. 26.8.1. Adding Items to the SiteMap
      2. 26.8.2. Using Buttons for Navigation
      3. 26.8.3. Building the Password Page
        1. 26.8.3.1. Writing the Code-Behind for Password.aspx
      4. 26.8.4. Building the NewUser.aspx page
    9. 26.9. Working with Data
      1. 26.9.1. Creating the XML Database
      2. 26.9.2. Working with the GridView Control
      3. 26.9.3. Further Configuration of the GridView Control
        1. 26.9.3.1. Working with the Select Button
        2. 26.9.3.2. Creating the SQL Database
    10. 26.10. Building the Computers.aspx Page
      1. 26.10.1. Adding the DropDownList Control
      2. 26.10.2. Adding the DetailsView Control
      3. 26.10.3. Further Configuring the DetailsView Control
    11. 26.11. Building the Report.aspx page
      1. 26.11.1. Adding the MicrosoftReportViewer Control
      2. 26.11.2. Creating the Report
    12. 26.12. The Bottom Line
  31. 27. ASP.NET Web Services
    1. 27.1. Using ASP.NET Web Services and WCF
      1. 27.1.1. ASP.NET Web Services
      2. 27.1.2. Windows Communication Foundation (WCF)
    2. 27.2. Understanding Technologies Associated with Web Services
      1. 27.2.1. SOAP
      2. 27.2.2. Web Services Description Language (WSDL)
      3. 27.2.3. SOAP Discovery
      4. 27.2.4. Universal Description, Discovery, and Integration (UDDI)
    3. 27.3. Creating a SimpleASP.NETWebService
      1. 27.3.1. Setting Up the Web Service
      2. 27.3.2. Testing the Web Service
      3. 27.3.3. Consuming the Web Service
    4. 27.4. Developing a Stand-AloneWebService
      1. 27.4.1. Building MyWebService
      2. 27.4.2. Deploying MyWebService
      3. 27.4.3. Consuming MyWebService
        1. 27.4.3.1. Adding a Web Reference
        2. 27.4.3.2. Adding the Code-Behind
    5. 27.5. Simple AJAX Implementation
    6. 27.6. The Bottom Line
  32. A. The Bottom Line
    1. A.1. Chapter 1: Getting StartedwithVisual Basic 2008
    2. A.2. Chapter 2: Variables and Data Types
    3. A.3. Chapter 3: Programming Fundamentals
    4. A.4. Chapter 4: GUI Design and Event-Driven Programming
    5. A.5. Chapter 5: The Vista Interface
    6. A.6. Chapter 6: Basic Windows Controls
    7. A.7. Chapter 7: Working with Forms
    8. A.8. Chapter 8: More Windows Controls
    9. A.9. Chapter 9: The TreeView and ListView Controls
    10. A.10. Chapter 10: Building Custom Classes
    11. A.11. Chapter 11: Working with Objects
    12. A.12. Chapter 12: Building Custom Windows Controls
    13. A.13. Chapter 13: Handling Strings, Characters, and Dates
    14. A.14. Chapter 14: StoringData in Collections
    15. A.15. Chapter 15: Accessing Folders and Files
    16. A.16. Chapter 16: Serialization and XML
    17. A.17. Chapter 17: Querying Collections and XML with LINQ
    18. A.18. Chapter 18: Drawing and Painting with Visual Basic 2008
    19. A.19. Chapter 19: Manipulating Images and Bitmaps
    20. A.20. Chapter 20: Printing with Visual Basic 2008
    21. A.21. Chapter 21: Basic Concepts of Relational Databases
    22. A.22. Chapter 22: Programming with ADO.NET
    23. A.23. Chapter 23: Building Data-Bound Applications
    24. A.24. Chapter 24: Advanced DataSet Operations
    25. A.25. Chapter 25: Building Web Applications
    26. A.26. Chapter 26: ASP.NET 3.5
    27. A.27. Chapter 27: ASP.Net Web Services
  33. B. Error Handling and Debugging
    1. B.1. Understanding the Types of Errors
      1. B.1.1. Design-Time Errors
      2. B.1.2. Runtime Errors
      3. B.1.3. Logic Errors
    2. B.2. Working with Exceptions and Structured Exception Handling
      1. B.2.1. Studying an Exception
      2. B.2.2. Getting a Handle on This Exception
      3. B.2.3. Wrapping Up with the Finally Clause
      4. B.2.4. VB 2008 at Work: The ReadWriteFile Project
      5. B.2.5. Customizing Exception Handling
      6. B.2.6. Throwing Custom Exceptions
        1. B.2.6.1. The Exception Class
        2. B.2.6.2. A Generic Exception Handler
    3. B.3. Debugging
      1. B.3.1. Setting Breakpoints
      2. B.3.2. Stepping Through
      3. B.3.3. Using the Local and Watch Windows

Product information

  • Title: Mastering Microsoft® Visual Basic® 2008
  • Author(s): Evangelos Petroutsos
  • Release date: March 2008
  • Publisher(s): Sybex
  • ISBN: 9780470187425