You are previewing Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition.
O'Reilly logo
Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition

Book Description


“The discussion of object-oriented programming is one of the best available.”
—Gavin Osborne, Saskatchewan Institute of Applied Science & Technology

“The explanation of UML, intelligently integrated into the book, conveys the heart and soul of true object oriented architecture and engineering.”
—Jeff Jones, Route Match Software

“The optional ATM OOD/UML case study is excellent! The implementation of the design gives the reader a fantastic model of a real world problem. You hit a home run with this one.”
—Catherine Wyman, Devry-Phoenix

“A superb job of clearly integrating the theory of relational databases and SQL with the application of ADO.NET.”
—Harlan Brewer, SES Consulting

“Really nails most everything you need to know about handling exceptions in VB.”
—Eric Gruber, Microsoft

“Excellent coverage of the most important features and techniques of developing ASP.NET 2.0 applications, with plenty of sample code.”
—Peter Bromberg, Senior Enterprise Architect, VOIP, Inc.

“A very impressive introduction to XML.”
—John Z. Chen, Microsoft

“An excellent chapter on Web services with great examples.”
—Chadi Boudiab, Georgia Perimeter College

“The best description of generics I’ve seen!”
—James Huddleston, Independent Consultant

The practicing programmer’s DEITEL® guide to Visual Basic and the powerful Microsoft .NET Framework

Written for C#, C++, Java or other-high level language programmers, this book applies the Deitel signature live-code approach to teaching programming and explores Microsoft’s Visual Basic language and the new .NET 2.0 in depth. The book is updated for Visual Studio® 2005 and presents Visual Basic concepts in fully tested programs, complete with syntax shading, line-by-line code descriptions, and program outputs. The book features 200+ applications with 16,000+ lines of proven Visual Basic code, and hundreds of programming tips that help you build robust applications.

Start with a concise introduction to Visual Basic fundamentals using an early classes and objects approach, then rapidly move on to more advanced topics, including multithreading, XML, ADO.NET 2.0, ASP.NET 2.0, Web services, network programming, .NET remoting, generics and collections. Along the way you’ll enjoy the Deitels’ classic treatment of object-oriented programming and a new, OOD/UML ATM case study, including a complete Visual Basic implementation. When you are finished, you’ll be well on your way to building next generation Windows applications, Web applications, and Web services.

Paul J. Deitel and Harvey M. Deitel are the founders of Deitel & Associates, Inc., the internationally recognized programming languages content-creation and corporate training organization. Together with their colleagues at Deitel & Associates, Inc., they have written many international best-selling programming languages textbooks and professional books that millions of people worldwide have used to master C, C++, Java, C#, XML, Visual Basic®, Perl, Python, and Internet and Web programming.

The DEITEL® Developer Series presents focused treatments of leading-edge technologies, including .NET development, Java development, Web services, and more.

Practical, Example-Rich Coverage Of:

  • Visual Basic 2005, .NET 2.0, FCL

  • ASP.NET 2.0, Web Forms and Controls

  • Database, SQL, and ADO.NET 2.0

  • Networking and .NET Remoting

  • XML, Web Services

  • Generics, Collections

  • GUI/Windows® Forms

  • OOP: Classes, Inheritance, and Polymorphism

  • OOD/UML ATM Case Study

  • Graphics and Multimedia

  • Multithreading

  • Exception Handling

  • And more...


  • Download code examples

  • Check out the extensive Visual Basic Resource Center

  • Check out the growing list of programming, Web 2.0, and software-related Resource Centers

  • To receive updates on this book, subscribe to the free DEITEL® BUZZ ONLINE e-mail newsletter at

  • Read archived issues of the DEITEL® BUZZ ONLINE

  • Contact for information on corporate training courses delivered on-site worldwide

  • CD contains Microsoft’s Visual Basic 2005 Express Edition

    Table of Contents

    1. Copyright
    2. Introduction to .NET, Visual Basic and Object Technology
      1. Introduction
      2. Microsoft’s Windows® Operating System
      3. Visual Basic
      4. The Internet and the World Wide Web
      5. Extensible Markup Language (XML)
      6. Microsoft’s .NET
      7. The .NET Framework and the Common Language Runtime
      8. Test-Driving a Visual Basic Application
      9. (Only Required Section of the Case Study) Software Engineering Case Study: Introduction to Object Technology and the UML
      10. Wrap-Up
      11. Web Resources
    3. Introduction to the Visual Basic Express 2005 IDE
      1. Introduction
      2. Overview of the Visual Studio 2005 IDE
      3. Menu Bar and Toolbar
      4. Navigating the Visual Studio IDE
      5. Using Help
      6. Using Visual Programming to Create a Simple Program that Displays Text and an Image
      7. Wrap-Up
      8. Web Resources
    4. Introduction to Visual Basic Programming
      1. Introduction
      2. Displaying a Line of Text
      3. Creating A Console Application in Visual Basic Express
      4. Displaying a Single Line of Text with Multiple Statements
      5. Adding Integers
      6. Arithmetic
      7. Decision Making: Equality and Relational Operators
      8. Using a Message Dialog to Display a Message
      9. (Optional) Software Engineering Case Study: Examining the ATM Requirements Document
      10. Wrap-Up
      11. Web Resources
    5. Introduction to Classes and Objects
      1. Introduction
      2. Classes, Objects, Methods and Instance Variables
      3. Declaring a Class with a Method and Instantiating an Object of a Class
      4. Declaring a Method with a Parameter
      5. Instance Variables and Properties
      6. Value Types and Reference Types
      7. Initializing Objects with Constructors
      8. Validating Data with Set Accessors in Properties
      9. (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements Document
      10. Wrap-Up
    6. Control Statements: Part 1
      1. Introduction
      2. Control Structures
      3. If...Then Selection Statement
      4. If...Then...Else Selection Statement
      5. While Repetition Statement
      6. Do While...Loop Repetition Statement
      7. Do Until...Loop Repetition Statement
      8. Compound Assignment Operators
      9. Counter-Controlled Repetition
      10. Sentinel-Controlled Repetition
      11. Nested Control Statements
      12. Nested Repetition Statements
      13. Visual Basic Programming in a Windows Application
      14. (Optional) Software Engineering Case Study: Identifying Class Attributes in the ATM System
      15. Wrap-Up
    7. Control Statements: Part 2
      1. Introduction
      2. Essentials of Counter-Controlled Repetition
      3. For...Next Repetition Statement
      4. Examples Using the For...Next Statement
      5. GradeBook Case Study: Select...Case Multiple-Selection Statement
      6. Do...Loop While Repetition Statement
      7. Do...Loop Until Repetition Statement
      8. Using the Exit Statement in Repetition Statements
      9. Using the Continue Statement in Repetition Statements
      10. Logical Operators
      11. (Optional) Software Engineering Case Study: Identifying Objects’ States and Activities in the ATM System
      12. Software Engineering Case Study Self-Review Exercises
      13. Wrap-Up
    8. Methods: A Deeper Look
      1. Introduction
      2. Modules, Classes and Methods
      3. Subroutines: Methods That Do Not Return a Value
      4. Functions: Methods That Return a Value
      5. Shared Methods and Class Math
      6. GradeBook Case Study: Declaring Methods with Multiple Parameters
      7. Notes on Declaring and Using Methods
      8. Method Call Stack and Activation Records
      9. Implicit Argument Conversions
      10. Option Strict and Data-Type Conversions
      11. Value Types and Reference Types
      12. Framework Class Library Namespaces
      13. Passing Arguments: Pass-by-Value vs. Pass-by-Reference
      14. Scope of Declarations
      15. Case Study: Random Number Generation
      16. Case Study: A Game of Chance
      17. Method Overloading
      18. Optional Parameters
      19. Recursion
      20. (Optional) Software Engineering Case Study: Identifying Class Operations in the ATM System
      21. Wrap-Up
    9. Arrays
      1. Introduction
      2. Arrays
      3. Declaring and Allocating Arrays
      4. Examples Using Arrays
      5. Case Study: Card Shuffling and Dealing Simulation
      6. Passing an Array to a Method
      7. For Each...Next Repetition Statement
      8. GradeBook Case Study: Using an Array to Store Grades
      9. Rectangular Arrays
      10. GradeBook Case Study: Using a Rectangular Array
      11. Variable-Length Parameter Lists
      12. Jagged Arrays
      13. Changing the Size of an Array at Execution Time: Using the ReDim Statement
      14. Passing Arrays: ByVal vs. ByRef
      15. (Optional) Software Engineering Case Study: Collaboration Among Objects in the ATM System
      16. Wrap-Up
    10. Classes and Objects: A Deeper Look
      1. Introduction
      2. Time Class Case Study
      3. Class Scope
      4. Default and Parameterless Constructors
      5. Time Class Case Study: Overloaded Constructors
      6. Partial Classes
      7. Composition
      8. Using the Me Reference to Access the Current Object
      9. Garbage Collection
      10. Shared Class Members
      11. Const and ReadOnly Members
      12. Object Browser
      13. Time Class Case Study: Creating Class Libraries
      14. (Optional) Software Engineering Case Study: Starting to Program the Classes of the ATM System
      15. Wrap-Up
    11. Object-Oriented Programming: Inheritance
      1. Introduction
      2. Base Classes and Derived Classes
      3. Protected Members
      4. Relationship between Base Classes and Derived Classes
      5. Constructors in Derived Classes
      6. Software Engineering with Inheritance
      7. Class Object
      8. Friend Members
      9. Wrap-Up
    12. Object-Oriented Programming: Polymorphism
      1. Introduction
      2. Polymorphic Video Game
      3. Demonstrating Polymorphic Behavior
      4. Abstract Classes and Methods
      5. Case Study: Payroll System Class Hierarchy Using Polymorphism
      6. NotOverridable Methods and NotInheritable Classes
      7. Case Study: Creating and Using Interfaces
      8. (Optional) Software Engineering Case Study: Incorporating Inheritance and Polymorphism into the ATM System
      9. Wrap-Up
    13. Exception Handling
      1. Introduction
      2. Exception Handling Overview
      3. Example: Divide by Zero Without Exception Handling
      4. Example: Handling DivideByZeroExceptions and FormatExceptions
      5. .NET Exception Hierarchy
      6. Finally Block
      7. Exception Properties
      8. User-Defined Exception Classes
      9. Wrap-Up
    14. Graphical User Interface Concepts: Part I
      1. Introduction
      2. Windows Forms
      3. Event Handling
      4. Control Properties and Layout
      5. Labels, TextBoxes and Buttons
      6. GroupBoxes and Panels
      7. CheckBoxes and RadioButtons
      8. PictureBoxes
      9. ToolTips
      10. NumericUpDown Control
      11. Mouse-Event Handling
      12. Keyboard-Event Handling
      13. Wrap-Up
    15. Graphical User Interface Concepts: Part 2
      1. Introduction
      2. Menus
      3. MonthCalendar Control
      4. DateTimePicker Control
      5. LinkLabel Control
      6. ListBox Control
      7. CheckedListBox Control
      8. ComboBox Control
      9. TreeView Control
      10. ListView Control
      11. TabControl Control
      12. Multiple Document Interface (MDI) Windows
      13. Visual Inheritance
      14. User-Defined Controls
      15. Wrap-Up
    16. Multithreading
      1. Introduction
      2. Thread States: Life Cycle of a Thread
      3. Thread Priorities and Thread Scheduling
      4. Creating and Executing Threads
      5. Thread Synchronization and Class Monitor
      6. Producer/Consumer Relationship without Thread Synchronization
      7. Producer/Consumer Relationship with Thread Synchronization
      8. Producer/Consumer Relationship: Circular Buffer
      9. Multithreading with GUIs
      10. Wrap-Up
    17. Strings, Characters and Regular Expressions
      1. Introduction
      2. Fundamentals of Characters and Strings
      3. String Constructors
      4. String Indexer, Length Property and CopyTo Method
      5. Comparing Strings
      6. Locating Characters and Substrings in Strings
      7. Extracting Substrings from Strings
      8. Concatenating Strings
      9. Miscellaneous String Methods
      10. Class StringBuilder
      11. Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder
      12. Append and AppendFormat Methods of Class StringBuilder
      13. Insert, Remove and Replace Methods of Class StringBuilder
      14. Char Methods
      15. Card Shuffling and Dealing Simulation
      16. Regular Expressions and Class RegEx
      17. Wrap-Up
    18. Graphics and Multimedia
      1. Introduction
      2. Drawing Classes and the Coordinate System
      3. Graphics Contexts and Graphics Objects
      4. Color Control
      5. Font Control
      6. Drawing Lines, Rectangles and Ovals
      7. Drawing Arcs
      8. Drawing Polygons and Polylines
      9. Advanced Graphics Capabilities
      10. Introduction to Multimedia
      11. Loading, Displaying and Scaling Images
      12. Animating a Series of Images
      13. Windows Media Player
      14. Microsoft Agent
      15. Wrap-Up
    19. Files and Streams
      1. Introduction
      2. Data Hierarchy
      3. Files and Streams
      4. Classes File and Directory
      5. Creating a Sequential-Access Text File
      6. Reading Data from a Sequential-Access Text File
      7. Case Study: A Credit-Inquiry Program
      8. Serialization
      9. Creating a Sequential-Access File Using Object Serialization
      10. Reading and Deserializing Data from a Sequential-Access Text File
      11. Wrap-Up
    20. Extensible Markup Language (XML)
      1. Introduction
      2. XML Basics
      3. Structuring Data
      4. XML Namespaces
      5. Document Type Definitions (DTDs)
      6. W3C XML Schema Documents
      7. (Optional) Extensible Stylesheet Language and XSL Transformations
      8. (Optional) Document Object Model (DOM)
      9. (Optional) Schema Validation with Class XmlReader
      10. (Optional) XSLT with Class XslCompiledTransform
      11. Wrap-Up
      12. Web Resources
    21. Database, SQL and ADO.NET
      1. Introduction
      2. Relational Databases
      3. Relational Database Overview: Books Database
      4. SQL
      5. ADO.NET Object Model
      6. Programming with ADO.NET: Extracting Information from a Database
      7. Querying the Books Database
      8. Programming with ADO.NET: Address Book Case Study
      9. Using a DataSet to Read and Write XML
      10. Wrap-Up
      11. Web Resources
    22. ASP.NET 2.0, Web Forms and Web Controls
      1. Introduction
      2. Simple HTTP Transactions
      3. Multitier Application Architecture
      4. Creating and Running a Simple Web-Form Example
      5. Web Controls
      6. Session Tracking
      7. Case Study: Connecting to a Database in ASP.NET
      8. Case Study: Secure Books Database Application
      9. Wrap-Up
      10. Web Resources
    23. Web Services
      1. Introduction
      2. .NET Web Services Basics
      3. Simple Object Access Protocol (SOAP)
      4. Publishing and Consuming Web Services
      5. Session Tracking in Web Services
      6. Using Web Forms and Web Services
      7. User-Defined Types in Web Services
      8. Wrap-Up
      9. Web Resources
    24. Networking: Streams-Based Sockets and Datagrams
      1. Introduction
      2. Connection-Oriented vs. Connectionless Communication
      3. Protocols for Transporting Data
      4. Establishing a Simple TCP Server Using Stream Sockets
      5. Establishing a Simple TCP Client Using Stream Sockets
      6. Client/Server Interaction with Stream-Socket Connections
      7. Connectionless Client/Server Interaction with Datagrams
      8. Client/Server Tic-Tac-Toe Using a Multithreaded Server
      9. WebBrowser Class
      10. .NET Remoting
      11. Wrap-Up
    25. Data Structures
      1. Introduction
      2. Primitive-Type Structures; Boxing and Unboxing
      3. Self-Referential Classes
      4. Linked Lists
      5. Stacks
      6. Queues
      7. Trees
      8. Wrap-Up
    26. Generics
      1. Introduction
      2. Motivation for Generic Methods
      3. Generic Method Implementation
      4. Type Constraints
      5. Overloading Generic Methods
      6. Generic Classes
      7. Notes on Generics and Inheritance
      8. Wrap-Up
    27. Collections
      1. Introduction
      2. Collections Overview
      3. Class Array and Enumerators
      4. Non-Generic Collections
      5. Generic Collections
      6. Synchronized Collections
      7. Wrap-Up
    28. Operator Precedence Chart
    29. Number Systems
      1. Introduction
      2. Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
      3. Converting Octal and Hexadecimal Numbers to Binary Numbers
      4. Converting from Binary, Octal or Hexadecimal to Decimal
      5. Converting from Decimal to Binary, Octal or Hexadecimal
      6. Negative Binary Numbers: Two’s Complement Notation
    30. Using the Visual Studio 2005 Debugger
      1. Introduction
      2. Breakpoints and the Continue Command
      3. The Locals and Watch Windows
      4. Controlling Execution Using the Step Into, Step Over, Step Out and Continue Commands
      5. Other Features
      6. Wrap-Up
    31. ASCII Character Set
    32. Unicode®
      1. Introduction
      2. Unicode Transformation Formats
      3. Characters and Glyphs
      4. Advantages/Disadvantages of Unicode
      5. Unicode Consortium’s Web Site
      6. Using Unicode
      7. Character Ranges
    33. Introduction to XHTML: Part 1
      1. Introduction
      2. Editing XHTML
      3. First XHTML Example
      4. W3C XHTML Validation Service
      5. Headers
      6. Linking
      7. Images
      8. Special Characters and More Line Breaks
      9. Unordered Lists
      10. Nested and Ordered Lists
      11. Web Resources
    34. Introduction to XHTML: Part 2
      1. Introduction
      2. Basic XHTML Tables
      3. Intermediate XHTML Tables and Formatting
      4. Basic XHTML Forms
      5. More Complex XHTML Forms
      6. Internal Linking
      7. Creating and Using Image Maps
      8. meta Elements
      9. frameset Element
      10. Nested framesets
      11. Web Resources
    35. XHTML Special Characters
    36. XHTML Colors
    37. ATM Case Study Code
      1. ATM Case Study Implementation
      2. Class ATM
      3. Class Screen
      4. Class Keypad
      5. Class CashDispenser
      6. Class DepositSlot
      7. Class Account
      8. Class BankDatabase
      9. Class Transaction
      10. Class BalanceInquiry
      11. Class Withdrawal
      12. Class Deposit
      13. Module ATMCaseStudy
      14. Wrap-Up
    38. UML 2: Additional Diagram Types
      1. Introduction
      2. Additional Diagram Types
    39. Primitive Types
      1. Additional Primitive Type Information
    40. CD-ROM Warranty
    41. Index