contents
Part I: Getting Familiar 1
Chapter 1: Basic Installation 3
Where Did Basic Come From? 3
And Then Came Visual Basic 4
The Old and the New 5
Let’s Get Started 6
What It Looks Like 7
The Major Components 9
Your First Program 11
Try It Out: Creating Your First Program 11
That Was Too Easy 12
Try It Out: Your Very Own Web Browser 13
Summary 15
Exercises 15
Chapter 2: Why Do All That Work? 17
Object-Oriented Programming 101 17
Starting Out Right 19
Try It Out: Using Starter Kits 20
Try It Out: Modifying Starter Kit Projects 23
Wizards, Too 25
Try It Out: Using a Wizard 26
Everything Is Optional 28
Try It Out: Customizing the Options 30
It’s All There in the Documentation 30
Summary 31
Exercises 32
Chapter 1: Basic Installation 3
Where Did Basic Come From? 3
And Then Came Visual Basic 4
The Old and the New 5
Let’s Get Started 6
What It Looks Like 7
The Major Components 9
Your First Program 11
Try It Out: Creating Your First Program 11
That Was Too Easy 12
Try It Out: Your Very Own Web Browser 13
Summary 15
Exercises 15
Chapter 2: Why Do All That Work? 17
Object-Oriented Programming 101 17
Starting Out Right 19
Try It Out: Using Starter Kits 20
Try It Out: Modifying Starter Kit Projects 23
Wizards, Too 25
Try It Out: Using a Wizard 26
Everything Is Optional 28
Try It Out: Customizing the Options 30
It’s All There in the Documentation 30
Summary 31
Exercises 32
Chapter 3: Using Databases 33
SQL Server Express 33
Data to Database 34
Try It Out: Creating the Database 41
Connecting Database to a Project 45
Try It Out: Connecting a Database and Project 47
Alternatives to SQL Server Express 48
Summary 49
Exercise 49
Chapter 4: What the User Sees 51
User Interface Basics 51
User Interface Fundamentals 52
Adding and Customizing Controls 53
Try It Out: Adding a Control to a Form 54
The Controls 55
Basic Controls 55
Layout Controls 58
Menu and Status Controls 59
Dialog Controls 61
Graphic Controls 61
Other Controls 62
Anchoring and Docking 63
Anchoring 63
Docking 64
Building the User Interface for the Personal Organizer 64
Try It Out: Creating the Main User Interface 64
Summary 67
Exercises 67
Chapter 5: How Do You Make That Happen? 69
Writing Code 69
The Basics of Basic 70
Try It Out: Writing Code #1 74
Want Something More? 76
Try It Out: Adding Conditional Code 77
Try It Out: Writing Event Handlers 82
Objects: A Special Case 83
Applying the Knowledge 83
Try It Out: Connecting User Interface Elements
SQL Server Express 33
Data to Database 34
Try It Out: Creating the Database 41
Connecting Database to a Project 45
Try It Out: Connecting a Database and Project 47
Alternatives to SQL Server Express 48
Summary 49
Exercise 49
Chapter 4: What the User Sees 51
User Interface Basics 51
User Interface Fundamentals 52
Adding and Customizing Controls 53
Try It Out: Adding a Control to a Form 54
The Controls 55
Basic Controls 55
Layout Controls 58
Menu and Status Controls 59
Dialog Controls 61
Graphic Controls 61
Other Controls 62
Anchoring and Docking 63
Anchoring 63
Docking 64
Building the User Interface for the Personal Organizer 64
Try It Out: Creating the Main User Interface 64
Summary 67
Exercises 67
Chapter 5: How Do You Make That Happen? 69
Writing Code 69
The Basics of Basic 70
Try It Out: Writing Code #1 74
Want Something More? 76
Try It Out: Adding Conditional Code 77
Try It Out: Writing Event Handlers 82
Objects: A Special Case 83
Applying the Knowledge 83
Try It Out: Connecting User Interface Elements
Part II: Extending Yourself Is Good 91
Chapter 6: Take Control of Your Program 93
Adding Some Class to Your Program 93
Creating Custom Classes 94
Special Method Actions 101
Try It Out: Creating a Class 103
Control Freaks Are Cool 104
Design-time Properties 105
Try It Out: Modifying the Menu and Toolbar 108
Custom Controls—Empower Yourself 111
Try It Out: Adding Properties to Persons 112
Go That Extra Mile 115
Try It Out: Creating Dynamic Buttons 116
Summary 119
Exercises 119
Chapter 7: Who Do You Call? 121
Using the Database Connection 121
An Alternate Method 124
What about Existing Controls? 125
Try It Out: Adding a Database to Personal Organizer 126
Database Programming 127
Actions You Can Perform 128
Try It Out: Accessing the Database through Code 129
Summary 141
Exercise 141
Chapter 8: It’s My World—Isn’t It? 143
They’re My Classes 143
It’s All about the Computer 144
Try It Out: Using the Clipboard 145
Try It Out: Accessing System Information 147
Try It Out: Sending Keystrokes with SendKeys 149
Getting to the App 153
Try It Out: Using My Project and My.Application 154
Chapter 6: Take Control of Your Program 93
Adding Some Class to Your Program 93
Creating Custom Classes 94
Special Method Actions 101
Try It Out: Creating a Class 103
Control Freaks Are Cool 104
Design-time Properties 105
Try It Out: Modifying the Menu and Toolbar 108
Custom Controls—Empower Yourself 111
Try It Out: Adding Properties to Persons 112
Go That Extra Mile 115
Try It Out: Creating Dynamic Buttons 116
Summary 119
Exercises 119
Chapter 7: Who Do You Call? 121
Using the Database Connection 121
An Alternate Method 124
What about Existing Controls? 125
Try It Out: Adding a Database to Personal Organizer 126
Database Programming 127
Actions You Can Perform 128
Try It Out: Accessing the Database through Code 129
Summary 141
Exercise 141
Chapter 8: It’s My World—Isn’t It? 143
They’re My Classes 143
It’s All about the Computer 144
Try It Out: Using the Clipboard 145
Try It Out: Accessing System Information 147
Try It Out: Sending Keystrokes with SendKeys 149
Getting to the App 153
Try It Out: Using My Project and My.Application 154
You Can Use It Again and Again . . . and Again 156
Try It Out: Using Code Snippets 156
Reusing Code Properly 158
Partial Classes 158
Generics 160
Try It Out: Adding the Login Form 162
Summary 167
Exercises 167
Chapter 9: Getting into the World 169
Creating a Web Browser 169
WebBrowser Properties 170
WebBrowser Methods 171
WebBrowser Events 172
Try It Out: Creating a Custom Web Browser Control 174
Web Services 179
Try It Out: Consuming a Web Service 181
Commercial Web Services 183
Try It Out: Web Service Registration 183
Amazon’s ItemSearch 184
Try It Out: Adding “Suggested Gift Ideas” 185
Visual Web Developer 2005 Express 196
Try It Out: Using Web Developer Express 196
Summary 198
Exercise 198
Chapter 10: When Things Go Wrong 199
Protecting Your Code 199
Try, Try, and Try Again 200
Try It Out: Using Try and Catch 201
Let the Others Know! 203
Try It Out: Throwing Exceptions Around 204
Troubleshooting Your Code 205
Telling the Program to Stop 205
Keeping Track of Variables 207
Try It Out: Using the Debug Object 210
Gone Too Far and Don’t Want to Stop? 211
Try It Out: Using Edit and Continue 212
Summary 213
Exercise 213
Try It Out: Using Code Snippets 156
Reusing Code Properly 158
Partial Classes 158
Generics 160
Try It Out: Adding the Login Form 162
Summary 167
Exercises 167
Chapter 9: Getting into the World 169
Creating a Web Browser 169
WebBrowser Properties 170
WebBrowser Methods 171
WebBrowser Events 172
Try It Out: Creating a Custom Web Browser Control 174
Web Services 179
Try It Out: Consuming a Web Service 181
Commercial Web Services 183
Try It Out: Web Service Registration 183
Amazon’s ItemSearch 184
Try It Out: Adding “Suggested Gift Ideas” 185
Visual Web Developer 2005 Express 196
Try It Out: Using Web Developer Express 196
Summary 198
Exercise 198
Chapter 10: When Things Go Wrong 199
Protecting Your Code 199
Try, Try, and Try Again 200
Try It Out: Using Try and Catch 201
Let the Others Know! 203
Try It Out: Throwing Exceptions Around 204
Troubleshooting Your Code 205
Telling the Program to Stop 205
Keeping Track of Variables 207
Try It Out: Using the Debug Object 210
Gone Too Far and Don’t Want to Stop? 211
Try It Out: Using Edit and Continue 212
Summary 213
Exercise 213
Part III: Making It Hum 215
Chapter 11: It’s Printing Time! 217
Timing Is Everything—Well, Almost 217
A Use for Timers 218
Try It Out: Using the Timer Effectively 220
Printing 224
Try It Out: Printing 226
System Components 231
Try It Out: Using System Components 232
Summary 239
Exercises 240
Chapter 12: Using XML 241
So What Is XML? 241
Extensible Means Just That 243
XML Attributes 244
Validating Data 244
Databases and XML 245
Try It Out: Exporting and Importing XML 246
The System.Xml Namespace 253
Try It Out: Creating a Wizard Form 256
Summary 277
Exercises 278
Chapter 13: Securing Your Program 279
Program Security 279
Role-Based Security 280
A Closer Look at Identity and Principal 282
Try It Out: Using Role-Based Security 282
Code-Based Security 283
Cryptography and Encryption 284
Secret Key Cryptography 285
Public Key Cryptography 285
Try It Out: Encrypting a Password 286
Summary 291
Exercise
Chapter 11: It’s Printing Time! 217
Timing Is Everything—Well, Almost 217
A Use for Timers 218
Try It Out: Using the Timer Effectively 220
Printing 224
Try It Out: Printing 226
System Components 231
Try It Out: Using System Components 232
Summary 239
Exercises 240
Chapter 12: Using XML 241
So What Is XML? 241
Extensible Means Just That 243
XML Attributes 244
Validating Data 244
Databases and XML 245
Try It Out: Exporting and Importing XML 246
The System.Xml Namespace 253
Try It Out: Creating a Wizard Form 256
Summary 277
Exercises 278
Chapter 13: Securing Your Program 279
Program Security 279
Role-Based Security 280
A Closer Look at Identity and Principal 282
Try It Out: Using Role-Based Security 282
Code-Based Security 283
Cryptography and Encryption 284
Secret Key Cryptography 285
Public Key Cryptography 285
Try It Out: Encrypting a Password 286
Summary 291
Exercise
Chapter 14: Getting It Out There 293
Installing the “Hard” Way 293
Just ClickOnce 294
Try It Out: Using ClickOnce 295
ClickOnce Options 299
ClickOnce Has Security and Signing, Too 302
Try It Out: Advanced Settings in ClickOnce 304
Summary 306
Exercise 306
Appendix A: Need More? What’s on the CD and Website 307
Appendix B: .NET—The Foundation 309
Appendix C: Answers to Exercises 317
Index 341
Installing the “Hard” Way 293
Just ClickOnce 294
Try It Out: Using ClickOnce 295
ClickOnce Options 299
ClickOnce Has Security and Signing, Too 302
Try It Out: Advanced Settings in ClickOnce 304
Summary 306
Exercise 306
Appendix A: Need More? What’s on the CD and Website 307
Appendix B: .NET—The Foundation 309
Appendix C: Answers to Exercises 317
Index 341