Cover image for Learning Visual Basic .NET

Book description

Most Visual Basic .NET books are written for experienced object-oriented programmers, but many programmers jumping on the .NET bandwagon are coming from non-object-oriented languages, such as Visual Basic 6.0 or from script programming, such as JavaScript. These programmers, and those who are adopting VB.NET as their first programming language, have been out of luck when it comes to finding a high-quality introduction to the language that helps them get started. That's why Jesse Liberty, author of the best-selling books Programming C# and Programming ASP.NET, has written an entry-level guide to Visual Basic .NET. Written in a warm and friendly manner, this book assumes no prior programming experience, and provides an easy introduction to Microsoft's most popular .NET language. Learning Visual Basic .NET is a complete introduction to VB.NET and object-oriented programming. This book will help you build a solid foundation in .NET, and show how to apply your skills by using hundreds of examples to help you become productive quickly. Learning Visual Basic .NET introduces fundamentals like Visual Studio .NET, a tool set for building Windows and Web applications. You'll learn about the syntax and structure of the Visual Basic .NET language, including operators, classes and interfaces, structs, arrays, and strings. Liberty then demonstrates how to develop various kinds of applications--including those that work with databases--and web services. By the time you've finished Learning Visual Basic .NET, you'll be ready to move on to a more advanced programming guide that will help you create large-scale web and Windows applications. Whether you have a little object-oriented programming experience or you are new to programming altogether, Visual Basic .NET will set you firmly on your way to mastering the essentials of the VB.NET language.

Table of Contents

  1. Learning Visual Basic .NET
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Preface
      1. About This Book
      2. Who This Book Is For
      3. How the Book Is Organized
      4. Conventions Used in This Book
      5. Support
      6. We'd Like to Hear from You
      7. Acknowledgments
    4. 1. Visual Basic .NET and .NET Programming
      1. 1.1. Visual Basic and .NET
        1. 1.1.1. Stepchild No Longer
      2. 1.2. The .NET Platform
      3. 1.3. The .NET Framework
      4. 1.4. The VB.NET Language
      5. 1.5. The Structure of VB.NET Applications
      6. 1.6. The Development Environment
    5. 2. Getting Started with VB.NET
      1. 2.1. What's in a Program?
      2. 2.2. Your First Program: Hello World
        1. 2.2.1. The Compiler
      3. 2.3. Examining Your First Program
        1. 2.3.1. Line-by-Line Analysis
    6. 3. Object-Oriented Programming
      1. 3.1. Creating Models
      2. 3.2. Classes and Objects
      3. 3.3. Defining a Class
      4. 3.4. Class Relationships
      5. 3.5. The Three Pillars of Object-Oriented Programming
      6. 3.6. Encapsulation
      7. 3.7. Specialization
      8. 3.8. Polymorphism
      9. 3.9. Object-Oriented Analysis and Design
    7. 4. Visual Studio .NET
      1. 4.1. Start Page
        1. 4.1.1. Projects and Solutions
        2. 4.1.2. Templates
      2. 4.2. Inside the Integrated Development Environment (IDE)
        1. 4.2.1. Layout
      3. 4.3. IntelliSense
      4. 4.4. Building and Running
      5. 4.5. For More Information
    8. 5. VB.NET Language Fundamentals
      1. 5.1. Types
        1. 5.1.1. Numeric Types
        2. 5.1.2. Non-Numeric Types: Boolean, Char, Date, and String
        3. 5.1.3. Types and Compiler Errors
      2. 5.2. Variables
        1. 5.2.1. Specifying Type with a Character
        2. 5.2.2. Initializing Variables
        3. 5.2.3. Default Values
      3. 5.3. Constants
        1. 5.3.1. Literal Constants
        2. 5.3.2. Symbolic Constants
        3. 5.3.3. Enumerations
        4. 5.3.4. About Casting
      4. 5.4. Strings
      5. 5.5. Statements
      6. 5.6. Whitespace
    9. 6. Branching
      1. 6.1. Unconditional Branching Statements
      2. 6.2. Conditional Branching Statements
        1. 6.2.1. If Statements
        2. 6.2.2. If . . . Else Statements
        3. 6.2.3. Nested If Statements
        4. 6.2.4. ElseIf
        5. 6.2.5. Select Case Statements
      3. 6.3. Iteration (Looping) Statements
        1. 6.3.1. Creating Loops with Goto
        2. 6.3.2. The Do Loop
        3. 6.3.3. Breaking out of a Do Loop
        4. 6.3.4. The For Loop
        5. 6.3.5. Controlling a For Loop Using Next
    10. 7. Operators
      1. 7.1. The Assignment Operator (=)
      2. 7.2. Mathematical Operators
        1. 7.2.1. Simple Arithmetical Operators (+, -, *, /, \)
        2. 7.2.2. The modulus Operator (Mod) to Return Remainders
        3. 7.2.3. The Exponentiation Operator (^)
      3. 7.3. Relational Operators
      4. 7.4. Logical Operators Within Conditionals
      5. 7.5. Operator Precedence
    11. 8. Classes and Objects
      1. 8.1. Defining Classes
        1. 8.1.1. Instantiating Objects
        2. 8.1.2. Modules Are Classes
        3. 8.1.3. Memory Allocation: The Stack Versus the Heap
        4. 8.1.4. Creating a Time Class
        5. 8.1.5. Access Modifiers
      2. 8.2. Method Arguments
      3. 8.3. Constructors
      4. 8.4. Initializers
      5. 8.5. Copy Constructors
      6. 8.6. The Me Keyword
      7. 8.7. Using Shared Members
      8. 8.8. Destroying Objects
    12. 9. Inside Methods
      1. 9.1. Overloading Methods
      2. 9.2. Encapsulating Data with Properties
        1. 9.2.1. The Get Accessor
        2. 9.2.2. The Set Accessor
        3. 9.2.3. ReadOnly and WriteOnly Properties
      3. 9.3. Passing by Value and by Reference
        1. 9.3.1. Passing Arguments by Value
        2. 9.3.2. Passing Arguments by Reference
        3. 9.3.3. Passing Reference Types by Value
    13. 10. Basic Debugging
      1. 10.1. Setting a Breakpoint
        1. 10.1.1. Using the Debug Menu to Set Your Breakpoint
        2. 10.1.2. Examining Values: The Autos and Locals Windows
        3. 10.1.3. Set Your Watch
      2. 10.2. The Call Stack
    14. 11. Inheritance and Polymorphism
      1. 11.1. Specialization and Generalization
      2. 11.2. Inheritance
        1. 11.2.1. Implementing Inheritance
        2. 11.2.2. Calling Base Class Constructors
        3. 11.2.3. Shadowing Base Methods
        4. 11.2.4. Controlling Access
      3. 11.3. Polymorphism
        1. 11.3.1. Creating Polymorphic Types
        2. 11.3.2. Creating Polymorphic Methods
        3. 11.3.3. Versioning with Overridable and Overrides
      4. 11.4. Abstract Classes
      5. 11.5. NotInheritable Classes
      6. 11.6. The Root of All Classes: Object
      7. 11.7. Boxing and Unboxing Types
        1. 11.7.1. Boxing Is Implicit
        2. 11.7.2. Unboxing Must Be Explicit
    15. 12. Structures
      1. 12.1. Defining a Structure
        1. 12.1.1. No Inheritance
        2. 12.1.2. No Initialization
        3. 12.1.3. Public Member Data?
    16. 13. Interfaces
      1. 13.1. Defining an Interface
      2. 13.2. Implementing an Interface
      3. 13.3. Implementing More Than One Interface
      4. 13.4. Casting to an Interface
        1. 13.4.1. The Is Operator
      5. 13.5. Extending Interfaces
      6. 13.6. Combining Interfaces
      7. 13.7. Overriding Interface Implementations
    17. 14. Arrays
      1. 14.1. Arrays
        1. 14.1.1. Declaring Arrays
        2. 14.1.2. The Size of the Array
        3. 14.1.3. The ReDim Keyword
        4. 14.1.4. Understanding Default Values
        5. 14.1.5. Accessing Array Elements
        6. 14.1.6. The For Each Statement
        7. 14.1.7. Initializing Array Elements
        8. 14.1.8. The ParamArray Keyword
      2. 14.2. Multidimensional Arrays
        1. 14.2.1. Rectangular Arrays
        2. 14.2.2. Jagged Arrays
      3. 14.3. System.Array
      4. 14.4. Indexers and the Default Property
        1. 14.4.1. Default Properties and Assignment
        2. 14.4.2. Indexing on Other Values
    18. 15. Collection Interfaces and Types
      1. 15.1. The Collection Interfaces
        1. 15.1.1. The IEnumerable Interface
        2. 15.1.2. Walking Through the For Each Loop in a Debugger
      2. 15.2. Array Lists
      3. 15.3. The Collection Class
      4. 15.4. Queues
      5. 15.5. Stacks
      6. 15.6. Copying from a Collection Type to an Array
    19. 16. Strings
      1. 16.1. Creating Strings
        1. 16.1.1. String Literals
        2. 16.1.2. The ToString( ) Method
        3. 16.1.3. Strings Are Immutable
      2. 16.2. Manipulating Strings
        1. 16.2.1. Comparing Strings
        2. 16.2.2. Concatenating Strings
        3. 16.2.3. Copying Strings
        4. 16.2.4. Testing for Equality
        5. 16.2.5. Other Useful String Methods
        6. 16.2.6. Finding Substrings
        7. 16.2.7. Splitting Strings
        8. 16.2.8. The StringBuilder Class
      3. 16.3. Regular Expressions
      4. 16.4. The Regex Class
    20. 17. Throwing and Catching Exceptions
      1. 17.1. Throwing Exceptions
      2. 17.2. Searching for an Exception Handler
      3. 17.3. The Throw Statement
      4. 17.4. The Try and Catch Statements
      5. 17.5. How the Call Stack Works
      6. 17.6. Creating Dedicated Catch Statements
      7. 17.7. The Finally Statement
      8. 17.8. Exception Class Methods and Properties
      9. 17.9. Custom Exceptions
    21. 18. Applications and Events
      1. 18.1. Creating a Windows Application
      2. 18.2. Events
        1. 18.2.1. Web Applications
      3. 18.3. Server-Side Code
    22. 19. Afterword
      1. 19.1. Where to Go from Here
      2. 19.2. Advanced Topics in VB.NET
      3. 19.3. Web (ASP.NET) Programming
      4. 19.4. Windows Forms Programming
      5. 19.5. Other Resources
    23. Index
    24. About the Author
    25. Colophon
    26. SPECIAL OFFER: Upgrade this ebook with O’Reilly