Sams Teach Yourself Microsoft Visual Basic .NET 2003 in 21 Days provides the grand tour of the software, making Visual Basic accessible and easy-to-use. Steve Holzner , the author, helps you master the topic by seeing Visual Basic in action from the basics to deploying finished Window and Web applications with a working example for every topic in the book. From cover to cover, this book is pure Visual Basic .NET¿everything you need to know about the Visual Basic language and visual tools. Sams Teach Yourself Microsoft® Visual Basic® .NET 2003 in 21 Days......Page 2 Copyright © 2003 by Sams Publishing......Page 3 Contents at a Glance......Page 4 Contents......Page 6 About the Author......Page 23 We Want to Hear from You!......Page 25 What’s in This Book......Page 26 The Conventions Used in This Book......Page 28 What You’ll Need......Page 29 Visual Basic .NET Resources Online......Page 30 Visual Basic .NET Essentials......Page 32 DAY 1 Getting Started with Visual Basic .NET!......Page 34 The History of Visual Basic......Page 35 Putting Visual Basic to Work......Page 37 Visual Basic .NET from a Programmer’s Perspective......Page 50 The Visual Basic .NET Integrated Development Environment......Page 58 Online Resources......Page 78 Summary......Page 80 Q&A......Page 81 Workshop......Page 82 DAY 2 Mastering the Visual Basic Language: Data, Operators, Conditionals, and Loops......Page 84 Visual Basic .NET Keywords......Page 85 Visual Basic .NET Statements......Page 87 Declaring Variables......Page 90 What Data Types Are Supported?......Page 92 Working with Strings......Page 94 Performing Data Conversions......Page 96 Declaring Constants......Page 100 Creating Enumerations......Page 101 Declaring Arrays and Dynamic Arrays......Page 102 Using Visual Basic Operators......Page 106 Making Decisions with If Statements......Page 110 Making Decisions with Select......Page 113 Making Decisions with Switch and Choose......Page 115 Using the For Loop......Page 117 Using the For Each Loop......Page 118 Using the While Loop......Page 119 Using the Do Loop......Page 121 Using the With Statement......Page 122 Ending a Program in Code......Page 123 Summary......Page 124 Workshop......Page 125 DAY 3 Mastering the Visual Basic Language: Procedures, Error Handling, Classes, and Objects......Page 128 Sub Procedures......Page 129 Creating Functions......Page 138 Using Optional Arguments......Page 141 Passing a Variable Number of Arguments......Page 142 Preserving Data Between Procedure Calls......Page 143 Understanding Scope......Page 145 Unstructured Exception Handling......Page 150 Structured Exception Handling......Page 157 Introducing Classes and Objects......Page 166 Q&A......Page 175 Workshop......Page 176 Visual Basic .NET Essentials......Page 178 Creating Windows Applications in Visual Basic .NET......Page 182 DAY 4 Creating Windows Forms......Page 184 Windows Forms in Overview......Page 185 Creating a Windows Application......Page 186 Windows Forms in Code......Page 191 Handling Windows Forms in Code......Page 198 Using the Built-in Message and Input Dialogs......Page 208 Creating Applications with Multiple Forms......Page 215 Creating MDI Applications......Page 219 Creating Dialogs......Page 222 Creating Owned Forms......Page 225 Using Nonrectangular Forms......Page 226 Creating Smart Device Applications......Page 227 Handling Mouse Events......Page 229 Handling Keyboard Events......Page 232 Summary......Page 237 Workshop......Page 238 DAY 5 Windows Forms: Working with Text Boxes, Buttons, Labels, Check Boxes, and Radio Buttons......Page 240 Overview of the Control Class......Page 241 Using Text Boxes......Page 245 Using Rich Text Boxes......Page 251 Using Labels......Page 258 Using Link Labels......Page 261 Using Buttons......Page 265 Using Check Boxes......Page 269 Using Radio Buttons......Page 272 Using Panels......Page 276 Using Group Boxes......Page 280 Summary......Page 281 Workshop......Page 282 DAY 6 Windows Forms: Working with List Boxes, Combo Boxes, Picture Boxes, Scrollbars, Splitters, Tool Tips, and Timers......Page 284 Using List Boxes......Page 285 Using Checked List Boxes......Page 294 Using Combo Boxes......Page 299 Using Picture Boxes......Page 304 Using Scrollbars......Page 308 Using Track Bars......Page 313 Using Splitters......Page 316 Using Notify Icons......Page 318 Using Tool Tips......Page 321 Using Timers......Page 323 Summary......Page 327 Workshop......Page 328 DAY 7 Windows Forms: Working with Menus, Built-in Dialogs, and Printing......Page 330 Using Menus......Page 331 Using Context Menus......Page 348 Using the Built-in Dialogs......Page 350 Using Open File Dialogs......Page 351 Using Save File Dialogs......Page 354 Using Font Dialogs......Page 357 Using Color Dialogs......Page 359 Using Folder Browser Dialogs......Page 362 Printing with the PrintDocument and PrintSettings Objects......Page 364 Using Print Dialogs......Page 367 Using Print Preview Dialogs......Page 370 Using Page Setup Dialogs......Page 371 Summary......Page 376 Workshop......Page 377 DAY 8 Windows Forms: Working with Image Lists, Tree Views, List Views, Toolbars, Status Bars, and Progress Bars......Page 380 Using Image Lists......Page 381 Using Tree Views......Page 385 Using List Views......Page 393 Using Toolbars......Page 403 Using Progress Bars......Page 409 Using Status Bars......Page 411 Using Tab Controls......Page 415 Summary......Page 419 Workshop......Page 420 Creating Windows Applications in Visual Basic .NET......Page 422 In-Depth Programming with Visual Basic .NET......Page 426 DAY 9 Object-Oriented Programming......Page 428 Constructors and Destructors......Page 431 Overloading Methods......Page 433 Creating Class (Shared) Members......Page 434 Supporting Events with Objects......Page 438 OOP with Structures and Modules......Page 441 Using Inheritance......Page 442 Using Access Modifiers......Page 445 Using Inheritance Modifiers......Page 449 Overloading, Overriding, and Shadowing with Inheritance......Page 450 Using MyBase and MyClass with Inheritance......Page 455 Inheriting Constructors......Page 458 Creating Interfaces......Page 459 Working with Polymorphism......Page 462 Understanding Early and Late Binding......Page 465 Summary......Page 467 Workshop......Page 468 DAY 10 Graphics and File Handling......Page 470 Graphics Handling......Page 471 Using the Graphics Class......Page 472 Using the Pen Class......Page 474 Drawing With Graphics Objects......Page 477 Setting Drawing Colors......Page 485 Filling In Figures......Page 486 Handling Images......Page 488 Drawing Text......Page 492 Using the FileStream Class......Page 494 Writing Text with the StreamWriter Class......Page 498 Reading Text with the StreamReader Class......Page 500 Reading Binary Data with the BinaryReader Class......Page 504 Writing Binary Data with the BinaryWriter Class......Page 507 Using the File and Directory Classes......Page 509 Summary......Page 513 Workshop......Page 514 In-Depth Programming with Visual Basic .NET......Page 516 Creating Web Applications in Visual Basic .NET......Page 520 DAY 11 Creating Web Forms with ASP.NET......Page 522 Creating Web Applications......Page 523 Know Your HTML......Page 528 Creating a Web Application......Page 532 Working with Web Forms......Page 534 Handling Events in Code......Page 538 Running a Web Application......Page 542 Customizing Web Page Appearance in HTML......Page 543 Preserving a Web Application’s Data Between Server Accesses......Page 547 Creating a Multiform Web Application......Page 549 Mobile Web Applications......Page 552 Handling Browser Programming in JavaScript......Page 553 Embedding Visual Basic Code in Web Pages......Page 556 Summary......Page 559 Workshop......Page 560 DAY 12 Web Forms: Working with Buttons, Text Boxes, Labels, Literals, and Placeholders......Page 562 Working with Web Server Controls......Page 566 Using Buttons......Page 577 Using Text Boxes......Page 581 Using Labels......Page 586 Using Literals......Page 589 Using Placeholders......Page 591 Using XML Controls......Page 594 Summary......Page 599 Workshop......Page 600 DAY 13 Web Forms: Working with Check Boxes, Radio Buttons, Tables, and Panels......Page 602 Using Check Boxes......Page 603 Using Check Box Lists......Page 607 Using Radio Buttons......Page 614 Using Radio Button Lists......Page 618 Using Tables......Page 621 Using Panels......Page 629 Summary......Page 633 Q&A......Page 634 Workshop......Page 635 DAY 14 Web Forms: Working with Images, Image Buttons, List Boxes, Drop-Down Lists, Hyperlinks, and Link Buttons......Page 636 Using Image Controls......Page 637 Using Image Buttons......Page 640 Using List Boxes......Page 643 Using Drop-Down Lists......Page 650 Using Hyperlinks......Page 655 Using Link Buttons......Page 659 Summary......Page 662 Q&A......Page 663 Workshop......Page 664 DAY 15 Web Forms: Working with Validation Controls, Calendars, and Ad Rotators......Page 666 Using Validation Controls......Page 667 Using Required Field Validators......Page 670 Using Comparison Validators......Page 672 Using Range Validators......Page 675 Using Regular Expression Validators......Page 676 Using Custom Validators......Page 680 Using Validation Summaries......Page 682 Using Calendars......Page 684 Using Ad Rotators......Page 689 Summary......Page 693 Q&A......Page 694 Workshop......Page 695 Creating Web Applications in Visual Basic .NET......Page 696 Working with Databases in Visual Basic .NET......Page 700 DAY 16 Handling Databases with ADO.NET......Page 702 What’s a Database?......Page 703 Connections, Data Adapters, and Datasets......Page 706 Connecting to Databases with the Server Explorer......Page 709 Working with Data Adapters......Page 717 Understanding ADO.NET......Page 724 An SQL Primer......Page 727 Handling Relational Databases......Page 732 Using Multiple Tables in One Dataset......Page 735 Working with Data Views......Page 739 Working with MS Jet Databases......Page 741 Summary......Page 745 Q&A......Page 746 Workshop......Page 747 DAY 17 Binding Visual Basic Controls to Databases......Page 750 Using Data Binding......Page 751 Creating Simple Data Binding......Page 752 Creating Complex Binding......Page 759 Navigating in Data Sources......Page 766 Creating Data Forms with the Data Form Wizard......Page 771 Data Validation in Data-Entry Forms......Page 777 Working with SQL Parameters......Page 780 Using Data Relation Objects......Page 783 Summary......Page 787 Q&A......Page 788 Workshop......Page 789 DAY 18 Handling Databases in Code......Page 792 Using Connection Objects......Page 793 Using Command Objects......Page 798 Using Data Adapters......Page 801 Using the DataSet Class......Page 806 Creating Datasets in Code......Page 808 Filling a DataSet with Your Own Data (No Data Source Needed)......Page 810 Creating a Data Relation in Code......Page 817 Reading the Data in a Table’s Cells in Code......Page 819 Using Data Readers......Page 822 Summary......Page 828 Q&A......Page 830 Workshop......Page 831 DAY 19 Using Databases in Web Applications......Page 832 Using Simple Data Binding......Page 836 Navigating Through Your Data......Page 838 Using Complex Data Binding......Page 842 Creating Master-Detail Data Forms......Page 860 Using Datasets Locally with Internet Explorer......Page 862 Summary......Page 864 Q&A......Page 865 Workshop......Page 866 Working with Databases in Visual Basic .NET......Page 868 Advanced Topics......Page 872 DAY 20 Creating User Controls, Web User Controls, and Multithreading......Page 874 Creating User Controls......Page 875 Creating Web User Controls......Page 885 Supporting Multithreading......Page 891 Synchronizing Threads......Page 898 Summary......Page 903 Workshop......Page 904 DAY 21 Creating Windows Services, Web Services, and Deploying Applications......Page 906 Creating Windows Services......Page 907 Creating Web Services......Page 921 Deploying Your Applications......Page 928 Summary......Page 935 Q&A......Page 937 Workshop......Page 938 Advanced Topics......Page 940 INDEX......Page 944