You are not signed in. Sign in.

Share:

Category IT Books

Microsoft Visual Basic 2010 Step by Step »

Book cover image of Microsoft Visual Basic 2010 Step by Step by Michael Halvorson

Authors: Michael Halvorson
ISBN-13: 9780735626690, ISBN-10: 0735626693
Format: Paperback
Publisher: Microsoft Press
Date Published: June 2010
Edition: (Non-applicable)

Find Best Prices for This Book »

Author Biography: Michael Halvorson

Michael Halvorson has written more than 30 books, including the popular Microsoft Visual Basic 2008 Step by Step, Microsoft Office XP Inside Out, and Microsoft Visual Basic 6.0 Professional Step by Step. A former Visual Basic localization manager at Microsoft, Michael is a professor at Pacific Lutheran University.

Book Synopsis

Your hands-on, step-by-step guide to learning Visual Basic® 2010.

Teach yourself the essential tools and techniques for Visual Basic® 2010-one step at a time. No matter what your skill level, you'll find the practical guidance and examples you need to start building professional applications for Windows® and the Web.

Discover how to:

  • Work in the Microsoft® Visual Studio® 2010 Integrated Development Environment (IDE)
  • Master essential techniques-from managing data and variables to using inheritance and dialog boxes
  • Create professional-looking UIs; add visual effects and print support
  • Build compelling Web features with the Visual Web Developer tool
  • Use Microsoft® ADO.NET and advanced data presentation controls
  • Debug your programs and handle run-time errors
  • Use new features, such as Query Builder, and Microsoft® .NET Framework
A Note Regarding the CD or DVD

The print version of this book ships with a CD or DVD. For those customers purchasing one of the digital formats in which this book is available, we are pleased to offer the CD/DVD content as a free download via O'Reilly Media's Digital Distribution services. To download this content, please visit O'Reilly's web site, search for the title of this book to find its catalog page, and click on the link below the cover image (Examples, Companion Content, or Practice Files). Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to booktech@oreilly.com.

Table of Contents

Acknowledgments

Introduction

Part I Getting Started with Microsoft Visual Basic 2010

1 Exploring the Visual Studio Integrated Development Environment 3

The Visual Studio Development Environment 4

The Visual Studio Tools 7

The Designer 10

Running a Visual Basic Program 11

The Properties Window 13

Moving and Resizing the Programming Tools 17

Moving and Resizing Tool Windows 18

Docking Tool Windows 19

Hiding Tool Windows 21

Switching Among Open Files and Tools by Using the IDE Navigator 22

Opening a Web Browser Within Visual Studio 23

Getting Help 24

Managing Help Settings 25

Using F1 Help 26

Customizing IDE Settings to Match Step-by-Step Exercises 29

Setting the IDE for Visual Basic Development 29

Checking Project and Compiler Settings 31

One Step Further: Exiting Visual Studio 33

Chapter 1 Quick Reference 34

2 Writing Your First Program 37

Lucky Seven: Your First Visual Basic Program 37

Programming Steps 38

Creating the User Interface 38

Setting the Properties 45

The Picture Box Properties 49

Writing the Code 52

A Look at the Button1_Click Procedure 56

Running Visual Basic Applications 58

Sample Projects on Disk 59

Building an Executable File 60

Deploying Your Application 62

One Step Further: Adding to a Program 63

Chapter 2 Quick Reference 64

3 Working with Toolbox Controls 67

The Basic Use of Controls: The Hello World Program 67

Using the DateTimePicker Control 73

The Birthday Program 73

Controls for Gathering Input 78

Using Group Boxes and Radio Buttons 81

Processing Input with List Boxes 84

A Word About Terminology 89

One Step Further: Using the LinkLabel Control 91

Chapter 3 Quick Reference 95

4 Working with Menus, Toolbars, and Dialog Boxes 97

Adding Menus by Using the MenuStrip Control 97

Adding Access Keys to Menu Commands 99

Processing Menu Choices 102

Adding Toolbars with the ToolStrip Control 107

Using Dialog Box Controls 110

Event Procedures That Manage Common Dialog Boxes 112

One Step Further: Assigning Shortcut Keys to Menus 117

Chapter 4 Quick Reference 119

Part II Programming Fundamentals

5 Visual Basic Variables and Formulas, and the .NET Framework 123

The Anatomy of a Visual Basic Program Statement 123

Using Variables to Store Information 124

Setting Aside Space for Variables: The Dim Statement 124

Implicit Variable Declaration 126

Using Variables in a Program 127

Using a Variable to Store Input 130

Using a Variable for Output 133

Working with Specific Data Types 135

Constants: Variables That Don't Change 142

Working with Visual Basic Operators 143

Basic Math: The +,-, and / Operators 144

Using Advanced Operators: \, Mod, ebugging Mode 212

Tracking Variables by Using a Watch Window 217

Visualizers: Debugging Tools That Display Data 220

Using the Immediate and Command Windows 221

Switching to the Command Window 223

One Step Further: Removing Breakpoints 224

Chapter 8 Quick Reference 225

9 Trapping Errors by Using Structured Error Handling 227

Processing Errors by Using the Try...Catch Statement 227

When to Use Error Handlers 228

Setting the Trap: The Try...Catch Code Block 229

Path and Disc Drive Errors 229

Writing a Disc Drive Error Handler 233

Using the Finally Clause to Perform Cleanup Tasks 234

More Complex Try...Catch Error Handlers 236

The Exception Object 236

Specifying a Retry Period 239

Using Nested Try...Catch Blocks 242

Comparing Error Handlers with Defensive Programming Techniques 242

One Step Further: The Exit Try Statement 243

Chapter 9 Quick Reference 244

10 Creating Modules and Procedures 247

Working with Modules 247

Creating a Module 248

Working with Public Variables 251

Creating Procedures 255

Writing Function Procedures 256

Function Syntax 257

Calling a Function Procedure 258

Using a Function to Perform a Calculation 258

Writing Sub Procedures 262

Sub Procedure Syntax 262

Calling a Sub Procedure 263

Using a Sub Procedure to Manage Input 264

One Step Further: Passing Arguments by Value and by Reference 268

Chapter 10 Quick Reference 270

11 Using Arrays to Manage Numeric and String Data 273

Working with Arrays of Variables 273

Creating an Array 274

Declaring a Fixed-Size Array 275

Setting Aside Memory 276

Working with Array Elements 277

Declaring an Array and Assigning It Initial Values 278

Creating a Fixed-Size Array to Hold Temperatures 279

Creating a Dynamic Array 283

Preserving Array Contents by Using ReDim Preserve 287

Using ReDim for Three-Dimensional Arrays 288

One Step Further: Processing Large Arrays by Using Methods in the Array Class 288

The Array Class 288

Chapter 11 Quick Reference 295

12 Working with Collections 297

Working with Object Collections 297

Referencing Objects in a Collection 298

Writing For Each...Next Loops 298

Experimenting with Objects in the Controls Collection 299

Using the Name Property in a For Each...Next Loop 302

Creating Your Own Collections 304

Declaring New Collections 304

One Step Further: VBA Collections 309

Entering the Word Macro 310

Chapter 12 Quick Reference 311

13 Exploring Text Files and String Processing 313

Reading Text Files 313

The My Namespace 314

The StreamReader Class 316

Using the ReadAllText Method 317

Writing Text Files 321

The WriteAllText Method 321

The StreamWriter Class 322

Using the WriteAllText Method 323

Processing Strings with the String Class 326

Sorting Text 329

Working with ASCII Codes 330

Sorting Strings in a Text Box 331

Examining the Sort Text Program Code 334

Protecting Text with Basic Encryption 336

One Step Further: Using the Xor Operator 340

Examining the Encryption Program Code 342

Chapter 13 Quick Reference 345

Part III Designing the User Interface

14 Managing Windows Forms and Controls at Run Time 351

Adding New Forms to a Program 351

How Forms Are Used 352

Working with Multiple Forms 352

Using the DialogResult Property in the Calling Form 358

Positioning Forms on the Windows Desktop 359

Minimizing, Maximizing, and Restoring Windows 364

Adding Controls to a Form at Run Time 364

Organizing Controls on a Form 367

One Step Further: Specifying the Startup Object 371

Chapter 14 Quick Reference 373

15 Adding Graphics and Animation Effects 375

Adding Artwork by Using the System Drawing Namespace 376

Using a Form's Coordinate System 376

The System.Drawing. Graphics Class 376

Using the Form's Paint Event 378

Adding Animation to Your Programs 380

Moving Objects on the Form 380

The Location Property 381

Creating Animation by Using a Timer Object 382

Expanding and Shrinking Objects While a Program is Running 386

One Step Further: Changing Form Transparency 388

Chapter 15 Quick Reference 390

16 Inheriting Forms and Creating Base Classes 393

Inheriting a Form by Using the Inheritance Picker 393

Creating Your Own Base Classes 399

Adding a New Class to Your Project 401

One Step Further: Inheriting a Base Class 408

Chapter 16 Quick Reference 412

17 Working with Printers 415

Using the PrintDocument Class 415

Printing Text from a Text Box Object 420

Printing Multipage Text Files 424

One Step Further: Adding Print Preview and Page Setup Dialog Boxes 430

Chapter 17 Quick Reference 437

Part IV Database and Web Programming

18 Getting Started with ADO.NET 441

Database Programming with ADO.NET 441

Database Terminology 442

Working with an Access Database 444

The Data Sources Window 452

Using Bound Controls to Display Database Information 458

One Step Further: SQL Statements, LINQ, and Filtering Data 461

Chapter 18 Quick Reference 466

19 Data Presentation Using the DataGridView Control 467

Using DataGridView to Display Database Records 467

Formatting DataGridView Cells 479

Adding a Second Data Grid View Object 482

One Step Further: Updating the Original Database 485

Chapter 19 Quick Reference 488

20 Creating Web Sites and Web Pages by Using Visual Web Developer and ASP.NET 491

Inside ASP.NET 491

Web Pages vs. Windows Forms 493

Server Controls 493

HTML Controls 494

Building a Web Site by Using Visual Web Developer 495

Considering Software Requirements for ASP.NET Programming 495

Using the Web Page Designer 498

Adding Server Controls to a Web Site 501

Writing Event Procedures for Web Page Controls 504

Customizing the Web Site Template 509

Displaying Database Records on a Web Page 512

One Step Further: Setting Web Site Titles in Internet Explorer 519

Chapter 20 Quick Reference 522

Appendix: Where to Go for More Information 523

Index 529

Subjects


 

 




No reviews. Submit yours!



Review this book.

We would like to know what you think about this book and publish your thoughts here! (top)

Your Review

  1. You may optionally give a title for this comment.

  2. Worst to best, 1 to 5, what would you rate this one?

  3. The actual content of your comment. No HTML nor whatsoever allowed.

  4. The author of this comment.

  5. Which is hot, ice or fire?

    Please answer the question by common sense.