About the Book
Take charge of Microsoft®
Visual Basic®—faster, smarter, better!
Now you can write your own programs with
Microsoft® Visual Basic® .NET—faster, smarter, and better. Dive
in—this friendly, high-energy guide makes it easy to learn exactly what
you need. Use the numbered steps, code listings, and expert tips to accelerate
your programming productivity—and move on to doing the cool things you
want to do!
• Learn basic concepts, syntax, and language
elements
• Follow easy coding techniques to build
your dexterity
• Write and run your first Visual Basic
.NET program
• Use built-in functions and classes or
create your own
• Design the user interface with Windows®
Forms
• Program Web applications using Microsoft
ASP.NET
• Access files and databases
• Debug and deploy your new programs
Related Books
Table of Contents
Acknowledgments xi
Introduction xiii
CHAPTER 1: Introducing
Basic Concepts 1
How Program
Code and Data Occupy Memory 2
Appreciating
Data Types 4
High-Level
Languages 5
The Concept
of Layered Software 7
Structured
Programming Constructs 9
Top-Down
Design 15
Subroutines
and Functions 17
Processing
Events 19
Classes
and Objects 20
Key Points
21
CHAPTER 2: Introducing
Microsoft Visual Basic .NET 23
Preparing
Your System 24
Preparing for .NET Windows Applications 24
Preparing for .NET Web Applications 25
Sizing Your Computer 26
Obtaining
Visual Basic .NET 26
Installing
Visual Basic .NET 27
Easing
into Visual Basic .NET 29
Manipulating
Visual Studio Windows 33
Help,
More Help, and Beyond Help 34
Understanding
Visual Basic .NET Syntax 36
Writing
and Running Your First Program 39
Key Points
48
CHAPTER 3: Using Elementary
Statements 51
Using
Data Types 52
Using
Literals 53
Using
Variables 54
Using
Constants 56
Option
Explicit and Option Strict 58
Working
with Arrays 60
Scoping
Out Variables 62
Writing
Decision Statements 63
Writing
Loops 65
Coding Loops with Do.Loop Statements 65
Coding Loops with For.Next Statements 66
Coding Loops with While.End While Statements 68
Example:
Writing a Tape Calculator 68
Key Points
75
CHAPTER 4: Using Operators
and Expressions 77
Introducing
Operators 78
Forming
Expressions 78
Using
Arithmetic Operators 80
Converting Numeric Types 81
Using
Assignment Operators 82
Using Compound Operators 83
Understanding Type Conversion 83
Assigning Reference Variables 85
Using
Comparison Operators 88
Comparing Numbers 88
Comparing Strings 89
Using the Like Operator 90
Getting
It Together with Concatenation Operators 92
Using
Logical Operators 92
Using Short-Circuited Operators 93
Using
Bitwise Operators 94
Using
Miscellaneous Operators 95
Testing
Operators and Expressions 95
Key Points
99
CHAPTER 5: Using Functions
and Subroutines 101
Introducing
Functions and Subroutines 101
Coding
Your Own Functions and Subroutines 102
Declaring
Arguments 103
Passing
Arguments by Value 104
Passing
Arguments by Reference 106
Sidestepping
Arguments 108
Specifying
Return Values 109
Exiting
Functions and Subroutines 112
Functions,
Subroutines, Variables, and Scope 112
Designing
Functions and Subroutines Effectively 114
Example:
Writing a Four-Function Calculator 114
Key Points
118
CHAPTER 6: Using Built-In
Functions 119
Finding
Built-In Functions 119
Using
Type Conversion Functions 124
Logical
Functions 124
Manipulating
Dates 126
Manipulating
Strings 129
Using
Array Functions 132
Generating
Random Numbers 133
Example:
Shuffling Cards 134
Initialize the Deck 134
Shuffle the Cards 138
Key Points
142
CHAPTER 7: Creating Classes
and Objects 143
The Deal
with Objects 144
A Touch of Class 144
Scrupulous Methods 144
Desirable Properties 145
Matters of Scope 146
Creating Objects from Classes 147
Example
1: Shuffling with Class 148
Construction
and Destruction 151
Using
Property Procedures 153
Using
Structures 156
Trying
Times and Exceptional Results 157
Example
2: Shuffling with Property Procedures 160
Form1.vb 163
Deck.vb 164
Key Points
165
CHAPTER 8: Using Classes,
Modules, and Forms 167
Using
.NET Framework Classes 168
Finding .NET Methods and Classes 168
Referencing Namespaces 172
Importing Namespaces 173
Making
the Most of Objects and Classes 174
Inheritance (and Not from Uncle Otto) 174
Overloading and Polymorphism 175
Events (i.e., Getting a Raise) 177
Using
Forms 180
Using
Modules 183
Example:
Dealing Cards 183
Creating the Main Form 184
Displaying the Player Forms 185
Moving the Player Forms 188
Declaring a Deck of Cards 189
Dealing the Cards 190
Ending the Game 192
Playing a Card 193
Key Points
200
CHAPTER 9: Designing and
Using Windows Forms 201
Designing
User Interfaces 202
Setting
Form and Control Properties 204
Using
Message Boxes 206
Finding
and Creating Icons 208
Example:
Creating a Picture Viewer 209
Creating the Picture Viewer Form 209
Creating the Picture Viewer Icons 211
Configuring the Form and Toolbar Icons 213
Specifying Assembly Information 216
Responding to File Exit and Help About Events 218
Displaying a Picture File 219
Copying a Picture to the Clipboard 224
Displaying a Picture from the Clipboard 225
Making the Toolbar Buttons Work 225
Key Points
229
CHAPTER 10: Interacting
with Windows Form Controls 231
Form
Control Categories 232
Adding
and Arranging Form Controls 234
Working
with Control Properties 236
Achieving Positions of Control 236
Oohs, Ahs, and Size 236
Amazing Disappearing Form Control Tricks 237
Tabs, Tab Orders, and TabIndex (But No Tab Dancing) 238
Working
With Text Boxes, Check Boxes, and Radio Buttons 239
Working
with List Boxes 239
Coping with Single-Selection List Boxes 241
Coping with Multiple-Selection ListBoxes 242
Adding and Removing ListBox Entries From Code 243
Responding
to Windows Form Control Events 244
Staging Keyboard Events 245
Snapshotting Focus Events 249
Listening for Click Events 251
Reacting to Mouse Events 252
Example:
Reporting Crocodiles 254
Creating the Crocodile Form 255
Validating the Input Fields 259
Writing the Output Record 265
Key Points
274
CHAPTER 11: Accessing Databases
275
SQL Concepts
and Syntax 278
Retrieving Data with the SELECT Statement 278
Coding the SELECT Clause 279
Coding the FROM Clause 280
Coding the WHERE Clause 280
Coding the GROUP BY Clause 281
Coding the HAVING Clause 281
Coding the ORDER BY Clause 281
Adding Data with the INSERT Statement 281
Changing Data with the UPDATE Statement 282
Removing Data with the DELETE Statement 283
Introducing
ADO.NET 283
Opening and Closing ADO.NET Connections 284
Using Command Objects 287
Using Data Readers 289
Using the DataAdapter, DataSet, and DataTable Objects 290
Displaying
and Updating a Database 294
Key Points
300
CHAPTER 12: Programming
Web Forms 301
Introducing
the Web 302
Creating
Web Projects 303
Examining
a New ASP.NET Web Application 305
Designing
Web Forms 307
The Life
Cycle of an ASP.NET Page 309
Adding
Controls to a Web Form 311
Using HTML Server Controls 311
Using Web Server Controls 313
Responding
to Web Form Events 314
Exchanging
Data with the Web Visitor 316
Testing
Your Web Project 317
Example:
Date Evaluator 319
Creating a Visual Web Page Design 319
Add the Code Behind the Date Evaluator Web Page 321
Key Points
323
INDEX 325 |