Cover image for Programming Visual Basic .NET

Book description

Programming Visual Basic .NET is the complete guide to application development using Visual Basic .NET. Targeted at programmers with some prior programming experience, the book covers the major areas of application development for Microsoft's new .NET platform. After starting with the traditional "hello world" application, the book discusses the two basic building blocks of any .NET application built with Visual Basic--the Visual Basic .NET programming language and the .NET Framework. Topics covered include:

  • Visual Basic language elements

  • Visual Basic's object-oriented language features

  • Programming with attributes

  • The Common Language Runtime

  • Garbage Collection and the Finalize and Dispose methods

  • Programmatically reading from and writing to .NET configuration files

  • Developing Multiple Document Interface (MDI) Windows Forms applications.

  • Handling form and control placement and resizing

  • Working with Windows Forms menus

  • Working with Windows Common Dialogs

  • Taking advantage of .NET printer services programmatically

  • Using ASP.NET HTML controls and Web controls

  • Understanding security in ASP.NET

  • Creating, discovering, and consuming web services

  • Accessing data in your .NET applications using ADO.NET

The remainder of the book focuses on the three major kinds of applications that can be developed with the .NET Framework: Windows Forms applications, ASP.NET applications, and web services. In each case, the book shows you how to build an application using Visual Studio .NET as well as using a text editor and the Visual Basic command-line compiler. This gives you an "under the hood" look at what Visual Studio is doing and allows you to gain a greater understanding of how a .NET application works--an understanding that you can take advantage of in building your own applications. Individual development topics covered in these chapters include:

Published just in time for the first release of Visual Studio .NET,Programming Visual Basic .NET is sure to become a key component of developers' .NET libraries.

Table of Contents

  1. Programming Visual Basic .NET
    1. Preface
      1. Organization of This Book
      2. Conventions Used in This Book
      3. How to Contact Us
      4. Acknowledgments
    2. 1. Introduction
      1. What Is the Microsoft .NET Framework?
      2. What Is Visual Basic .NET?
      3. An Example Visual Basic .NET Program
        1. hello, world
        2. Hello, Windows
        3. Hello, Browser
    3. 2. The Visual Basic .NET Language
      1. Source Files
      2. Identifiers
      3. Keywords
      4. Literals
        1. Numeric Literals
        2. String Literals
        3. Character Literals
        4. Date Literals
        5. Boolean Literals
        6. Nothing
        7. Summary of Literal Formats
      5. Types
        1. Fundamental Types
        2. Custom Types
        3. Arrays
          1. Initializing arrays
          2. Dynamically allocating arrays
        4. Collections
        5. Type Conversions
      6. Namespaces
        1. The Namespace Statement
        2. The Imports Statement
      7. Symbolic Constants
      8. Variables
        1. Variable Initializers
      9. Scope
      10. Access Modifiers
      11. Assignment
      12. Operators and Expressions
        1. Unary Operators
        2. Arithmetic Operators
        3. Relational Operators
        4. String-Concatenation Operators
        5. Bitwise Operators
        6. Logical Operators
        7. Operator Precedence
        8. Operator Overloading
      13. Statements
        1. Option Statements
        2. Branching Statements
          1. Call
          2. Exit
          3. Goto
          4. If
          5. RaiseEvent
          6. Return
          7. Select Case
        3. Iteration Statements
          1. Do
          2. For
          3. For Each
        4. Mathematical Functions
        5. Input/Output
      14. Classes
        1. Object Instantiation and New
        2. Constructors
        3. Fields
          1. Read-only fields
        4. Handling Events
        5. Inheritance
        6. Methods
          1. Method parameters
          2. Passing arrays as parameters
          3. Variable-length parameter lists
          4. Main method
          5. Implementing interface methods
          6. Overriding inherited methods
          7. Overloading
          8. Overloading inherited methods
          9. Shadowing
        7. Properties
        8. The Me and MyClass Keywords
        9. The MyBase Keyword
        10. Nested Classes
        11. Destructors
        12. Early Versus Late Binding
      15. Interfaces
      16. Structures
        1. Boxing and Unboxing
      17. Enumerations
      18. Exceptions
      19. Delegates
      20. Events
        1. Using Events and Delegates Together
      21. Standard Modules
      22. Attributes
        1. Creating Custom Attributes
        2. Reading Attributes
      23. Conditional Compilation
      24. Summary
    4. 3. The .NET Framework
      1. Common Language Infrastructure (CLI) and Common Language Runtime (CLR)
      2. Common Type System (CTS)
        1. Namespaces
      3. Portions of the CLI
      4. Modules and Assemblies
        1. Global Assembly Cache (GAC)
        2. Comparison of Assemblies, Modules, and Namespaces
      5. Application Domains
      6. Common Language Specification (CLS)
      7. Intermediate Language (IL) and Just-In-Time (JIT) Compilation
      8. Metadata
      9. Memory Management and Garbage Collection
        1. Finalize
        2. Dispose
      10. A Brief Tour of the .NET Framework Namespaces
      11. Configuration
        1. Configuration File Format
        2. Configuration Section Groups
        3. The <appSettings> Section
      12. Summary
    5. 4. Windows Forms I: Developing Desktop Applications
      1. Creating a Form
        1. Creating a Form Using Visual Studio .NET
          1. Adding event handlers
        2. Creating a Form in Code
          1. Adding event handlers
      2. Handling Form Events
      3. Relationships Between Forms
      4. MDI Applications
        1. Parent and Child Forms
        2. Creating a Window Menu
        3. Merging Menus
        4. Detecting MDI Child Window Activation
      5. Component Attributes
      6. 2-D Graphics Programming with GDI+
        1. The Graphics Class
        2. The Pen Class
        3. The Brush Class
        4. The Color Structure
          1. System colors
        5. Alpha Blending
        6. Antialiasing
      7. Printing
        1. Hello, Printer!
        2. The PrintPageEventArgs Class
        3. The OnBeginPrint and OnEndPrint Methods
        4. Choosing a Printer
        5. The PageSettings Class
        6. The PrinterSettings Class
        7. Page Setup Dialog Box
        8. Print Preview
        9. Summary of Printing
      8. Summary
    6. 5. Windows Forms II: Controls, Common Dialog Boxes, and Menus
      1. Common Controls and Components
        1. The Button Class
        2. The CheckBox Class
        3. The ComboBox Class
        4. The DateTimePicker Class
        5. The GroupBox Class
        6. The ImageList Class
        7. The Label Class
        8. The LinkLabel Class
        9. The ListBox Class
        10. The ListBox.ObjectCollection Class
        11. The ListView Class
        12. The MonthCalendar Class
        13. The Panel Class
        14. The PictureBox Class
        15. The RadioButton Class
        16. The TextBox Class
        17. The Timer Class
        18. Other Controls and Components
      2. Control Events
      3. Form and Control Layout
        1. The Anchor Property
        2. The Dock Property
          1. Controlling dock order
          2. The Splitter control
      4. Common Dialog Boxes
        1. ColorDialog
        2. FontDialog
        3. OpenFileDialog
        4. PageSetupDialog
        5. PrintDialog
        6. PrintPreviewDialog
        7. SaveFileDialog
      5. Menus
        1. Adding Menus in the Visual Studio .NET Windows Forms Designer
        2. Programmatically Creating Menus
        3. Handling Menu Events
        4. Cloning Menus
      6. Creating a Control
        1. Building Controls from Other Controls
        2. Building Controls That Draw Themselves
        3. Building Nonrectangular Controls
      7. Summary
    7. 6. ASP.NET and Web Forms: Developing Browser-Based Applications
      1. Creating a Web Form
        1. Creating a Form Using Visual Studio .NET
          1. Adding event handlers
        2. Creating a Form in Code
          1. Setting control properties using attributes
          2. Adding event handlers
      2. Handling Page Events
        1. AutoEventWireup
      3. More About Server Controls
        1. Web Controls
          1. The Button control
          2. The CheckBox control
          3. The DropDownList control
          4. The Image control
          5. The Label control
          6. The ListBox control
          7. The RadioButton control
          8. The Table control
          9. The TextBox control
          10. Other web controls
        2. HTML Controls
        3. Handling Control Events
        4. Programmatically Instantiating Controls
      4. Adding Validation
        1. More About Validation-Control Tag Attributes
        2. Using Validation-Control Properties
        3. Providing a Summary View of Validation Failures
        4. Performing Custom Validation
      5. Using Directives to Modify Web Page Compilation
      6. ASP.NET Objects: Interacting with the Framework
        1. The Server Object
        2. The Application Object
        3. The Session Object
        4. The Cache Object
        5. The Request Object
        6. The Response Object
      7. Discovering Browser Capabilities
      8. Maintaining State
        1. The Session Object
        2. The Application Object
        3. Cookies
      9. Application-Level Code and global.asax
        1. Session and Application Startup and Shutdown
        2. global.asax Compiles to a Class
        3. Adding Global Objects
      10. Web-Application Security
        1. Authentication
          1. Forms authentication
          2. Windows authentication
            1. Integrated Windows authentication
            2. Digest authentication
            3. Basic authentication
          3. Understanding authentication
        2. Authorization
          1. ASP.NET authorization
          2. Windows NTFS authorization
          3. Code-access authorization
        3. Accessing Network Resources
          1. IUSR_ComputerName
          2. Impersonation
      11. Designing Custom Controls
        1. User Controls
        2. Server Controls
          1. Creating a custom server control using Visual Studio .NET
          2. Creating a custom server control in code
          3. Using a custom server control in Visual Studio .NET
          4. Using a custom server control manually
      12. Summary
    8. 7. Web Services
      1. Creating a Web Service
        1. The WebService Attribute
        2. The WebMethod Attribute
        3. The WebService Class
      2. Testing a Web Service with a Browser
      3. Web-Service Descriptions
      4. Consuming a Web Service
        1. Consuming a Web Service in Visual Studio .NET
        2. Consuming a Web Service in Notepad
        3. Synchronous Versus Asynchronous Calls
      5. Web-Service Discovery
      6. Limitations of Web Services
      7. Summary
    9. 8. ADO.NET: Developing Database Applications
      1. A Brief History of Universal Data Access
      2. Managed Providers
      3. Connecting to a SQL Server Database
      4. Connecting to an OLE DB Data Source
      5. Reading Data into a DataSet
        1. The DataSet Class
        2. Finding Tables
        3. Finding Rows
          1. The Select method versus the SQL SELECT statement
        4. Finding Column Values
        5. Finding Column Definitions
        6. Changing, Adding, and Deleting Rows
        7. Writing Updates Back to the Data Source
      6. Relations Between DataTables in a DataSet
      7. The DataSet’s XML Capabilities
      8. Binding a DataSet to a Windows Forms DataGrid
      9. Binding a DataSet to a Web Forms DataGrid
      10. Typed DataSets
      11. Reading Data Using a DataReader
      12. Executing Stored ProceduresThrough a SqlCommand Object
      13. Summary
    10. A. Custom Attributes Defined in the System Namespace
      1. AttributeUsage
      2. CLSCompliant
      3. ContextStatic
      4. Flags
      5. LoaderOptimization
      6. MTAThread
      7. NonSerialized
      8. Obsolete
      9. ParamArray
      10. Serializable
      11. STAThread
      12. ThreadStatic
    11. B. Exceptions Defined in the System Namespace
    12. C. Cultures
    13. D. Resources for Developers
      1. .NET Information
      2. Discussion Lists
    14. E. Math Functions
    15. Index
    16. Colophon