Additional Information
Book Details
Abstract
If you are new to computer programming then this book is for you! Starting from scratch, it assumes no prior knowledge of programming and is written in a simple, direct style for maximum clarity. This third edition updates the text to incorporate Visual Basic 2008 the latest version of this robust, object-oriented language.
Table of Contents
Section Title | Page | Action | Price |
---|---|---|---|
Cover | cover | ||
Visual Basic 2008 for Students | i | ||
Contents | v | ||
Detailed contents | vii | ||
Preface | xviii | ||
The background to Visual Basic | 1 | ||
The history of Visual Basic | 1 | ||
The Microsoft .NET framework | 2 | ||
What is a program? | 2 | ||
Programming principles | 4 | ||
Programming pitfalls | 5 | ||
Summary | 5 | ||
Exercises | 5 | ||
Answers to Self-Test Questions | 6 | ||
The VB development environment | 7 | ||
Introduction | 7 | ||
Installation and configuration | 7 | ||
Creating a first program | 8 | ||
Controls at design-time | 13 | ||
Events and the Button control | 15 | ||
Opening an existing project | 17 | ||
Documenting property settings | 17 | ||
Program errors | 18 | ||
Editor facilities | 18 | ||
The message box | 20 | ||
Help | 21 | ||
Programming principles | 21 | ||
Programming pitfalls | 21 | ||
Grammar spot | 22 | ||
New language elements | 22 | ||
New IDE facilities | 22 | ||
Summary | 22 | ||
Exercises | 22 | ||
Answers to Self-Test Questions | 24 | ||
Introductory graphics | 25 | ||
Introduction | 25 | ||
Objects, methods, properties, classes – an analogy | 25 | ||
A first drawing | 26 | ||
Creating the program | 27 | ||
The graphics coordinate system | 28 | ||
Explanation of the program | 29 | ||
Methods for drawing | 30 | ||
Colours | 32 | ||
The sequence concept and statements | 34 | ||
Adding meaning with comments | 34 | ||
Programming principles | 35 | ||
Programming pitfalls | 35 | ||
Grammar spot | 35 | ||
New language elements | 35 | ||
Summary | 36 | ||
Exercises | 36 | ||
Answers To Self-Test Questions | 37 | ||
Variables and calculations | 38 | ||
Introduction | 38 | ||
The nature of Integer | 39 | ||
The nature of Double | 39 | ||
Declaring variables | 40 | ||
The assignment statement | 43 | ||
Calculations and operators | 43 | ||
The arithmetic operators | 45 | ||
The Mod operator | 47 | ||
Strings and numbers: the & operator | 48 | ||
Text boxes and labels | 50 | ||
The InputBox | 53 | ||
Converting between numbers | 53 | ||
The role of expressions | 54 | ||
Programming principles | 55 | ||
Programming pitfalls | 55 | ||
Grammar spot | 55 | ||
New language elements | 56 | ||
New IDE facilities | 56 | ||
Summary | 56 | ||
Exercises | 56 | ||
Answers to Self-Test Questions | 58 | ||
Methods and arguments | 60 | ||
Introduction | 60 | ||
Writing your own methods | 61 | ||
A first method | 61 | ||
Calling a method | 63 | ||
Passing arguments | 63 | ||
Parameters and arguments | 65 | ||
A triangle method | 66 | ||
Local variables | 69 | ||
Name clashes | 70 | ||
Event-handling methods | 71 | ||
Function methods and results | 71 | ||
Building on methods | 74 | ||
Passing arguments by reference | 77 | ||
References – an example | 78 | ||
References: a Swap method | 80 | ||
Me and objects | 81 | ||
Overloading | 82 | ||
Passing objects to methods | 83 | ||
Programming principles | 84 | ||
Programming pitfalls | 84 | ||
Grammar spot | 84 | ||
New language elements | 85 | ||
New IDE facilities | 85 | ||
Summary | 85 | ||
Exercises | 86 | ||
Answers to Self-Test Questions | 88 | ||
Using objects | 90 | ||
Introduction | 90 | ||
Instance variables | 90 | ||
The form constructor | 93 | ||
The TrackBar class | 95 | ||
Imports and namespaces | 97 | ||
Members, methods and properties | 98 | ||
The Random class | 99 | ||
The Timer class | 102 | ||
Programming principles | 105 | ||
Programming pitfalls | 105 | ||
Grammar spot | 105 | ||
New language elements | 105 | ||
New IDE facilities | 106 | ||
Summary | 106 | ||
Exercises | 106 | ||
Answers to Self-Test Questions | 108 | ||
Selection – If and Select | 109 | ||
Introduction | 109 | ||
The If statement | 110 | ||
Comparison operators | 114 | ||
And, or, Not | 115 | ||
Nested Ifs and ElseIf | 118 | ||
Select | 122 | ||
Boolean variables | 126 | ||
Programming principles | 129 | ||
Programming pitfalls | 129 | ||
Grammar spot | 129 | ||
New language elements | 130 | ||
Summary | 131 | ||
Exercises | 131 | ||
Answers to Self-Test Questions | 134 | ||
Repetition – For, While and Do | 136 | ||
Introduction | 136 | ||
For | 137 | ||
While | 140 | ||
And, Or, Not | 144 | ||
Do...Loop | 145 | ||
Nested loops | 146 | ||
Combining control structures | 148 | ||
Programming principles | 150 | ||
Programming pitfalls | 151 | ||
Grammar spot | 151 | ||
New language elements | 152 | ||
Summary | 152 | ||
Exercises | 152 | ||
Answers to Self-Test Questions | 155 | ||
Debugging | 157 | ||
Introduction | 157 | ||
Using the debugger | 159 | ||
Case study in debugging | 161 | ||
Common errors | 162 | ||
Programming pitfalls | 166 | ||
New IDE facilities | 166 | ||
Summary | 167 | ||
Exercise | 167 | ||
Writing classes | 168 | ||
Introduction | 168 | ||
Designing a class | 169 | ||
Private variables | 171 | ||
Public methods | 172 | ||
Properties | 174 | ||
Method or property? | 177 | ||
Constructors | 178 | ||
Multiple constructors | 178 | ||
Private methods | 179 | ||
Operations on objects | 180 | ||
Object destruction | 181 | ||
Shared methods and properties | 182 | ||
Programming principles | 183 | ||
Programming pitfalls | 185 | ||
Grammar spot | 186 | ||
New language elements | 186 | ||
Summary | 187 | ||
Exercises | 187 | ||
Answers to Self-Test Questions | 189 | ||
Inheritance | 191 | ||
Introduction | 191 | ||
Using inheritance | 192 | ||
Protected | 193 | ||
Additional items | 194 | ||
Overriding | 195 | ||
Class diagrams | 196 | ||
Inheritance at work | 197 | ||
MyBase | 197 | ||
Constructors | 198 | ||
Abstract classes | 200 | ||
Programming principles | 201 | ||
Programming pitfalls | 203 | ||
New language elements | 203 | ||
Summary | 203 | ||
Exercises | 204 | ||
Answers to Self-Test Questions | 205 | ||
Calculations | 206 | ||
Introduction | 206 | ||
Literals | 207 | ||
Formatting numbers | 207 | ||
Library mathematical functions and constants | 209 | ||
Constants | 210 | ||
Case study – money | 211 | ||
Case study – iteration | 213 | ||
Graphs | 213 | ||
Exceptions | 216 | ||
Programming principles | 218 | ||
Programming pitfalls | 218 | ||
Summary | 218 | ||
Exercises | 218 | ||
Answers to Self-Test Questions | 221 | ||
Data structures – list boxes and lists | 222 | ||
Introduction | 222 | ||
Lists | 223 | ||
Adding items to a list | 223 | ||
The length of a list | 224 | ||
Indices | 225 | ||
Removing items from a list | 227 | ||
Inserting items within a list | 227 | ||
Lookup | 227 | ||
Arithmetic on a list box | 229 | ||
For Each | 230 | ||
Searching | 231 | ||
Using a list – generics | 232 | ||
Methods and properties of lists | 233 | ||
Lists of objects | 235 | ||
Programming principles | 236 | ||
Programming pitfalls | 237 | ||
New language elements | 237 | ||
Summary | 237 | ||
Exercises | 238 | ||
Answers to Self-Test Questions | 238 | ||
Arrays | 239 | ||
Introduction | 239 | ||
Creating an array | 241 | ||
Indices | 241 | ||
The length of an array | 243 | ||
Passing arrays as parameters | 244 | ||
The For Each statement | 245 | ||
Using constants | 246 | ||
Initializing an array | 247 | ||
A sample program | 248 | ||
Lookup | 250 | ||
Searching | 250 | ||
Arrays of objects | 252 | ||
Programming principles | 254 | ||
Programming pitfalls | 254 | ||
Grammar spot | 255 | ||
Summary | 255 | ||
Exercises | 255 | ||
Answers to Self-Test Questions | 259 | ||
Arrays – two-dimensional | 261 | ||
Introduction | 261 | ||
Declaring an array | 262 | ||
Indices | 263 | ||
The size of an array | 264 | ||
Passing arrays as parameters | 265 | ||
Constants | 265 | ||
Initializing an array | 266 | ||
A sample program | 267 | ||
For Each statement | 269 | ||
Programming principles | 269 | ||
Programming pitfalls | 270 | ||
Summary | 270 | ||
Exercises | 270 | ||
Answers to Self-Test Questions | 273 | ||
String manipulation | 274 | ||
Introduction | 274 | ||
Using strings – a recap | 274 | ||
String indexing | 276 | ||
The characters within strings | 276 | ||
Comparing strings | 276 | ||
The String class methods and properties | 277 | ||
Amending strings | 277 | ||
Examining strings | 279 | ||
An example of string processing | 283 | ||
Case study – Ask Frasier | 285 | ||
Programming principles | 287 | ||
Programming pitfalls | 287 | ||
Grammar spot | 287 | ||
New language elements | 288 | ||
New IDE facilities | 288 | ||
Summary | 288 | ||
Exercises | 288 | ||
Answers to Self-Test Questions | 289 | ||
Exceptions | 290 | ||
Introduction | 290 | ||
The jargon of exceptions | 292 | ||
A Try-Catch example | 292 | ||
Using the exception object | 295 | ||
Classifying exceptions | 295 | ||
Multiple Catch blocks | 297 | ||
The search for a catcher | 297 | ||
Throwing – an introduction | 299 | ||
Handling – some possibilities | 300 | ||
Finally | 301 | ||
Programming principles | 301 | ||
Programming pitfalls | 302 | ||
Grammar spot | 302 | ||
New language elements | 302 | ||
New IDE facilities | 302 | ||
Summary | 303 | ||
Exercises | 303 | ||
Answers to Self-Test Questions | 304 | ||
Files | 305 | ||
Introduction | 305 | ||
The essentials of streams | 306 | ||
The Stream Reader and Stream Writer classes | 306 | ||
File output | 307 | ||
File input | 308 | ||
File searching | 311 | ||
Files and exceptions | 313 | ||
Message boxes and dialogs | 315 | ||
Using file dialogs | 316 | ||
Creating a menu | 318 | ||
The Directory class | 321 | ||
Programming principles | 324 | ||
Programming pitfalls | 324 | ||
Grammar spot | 324 | ||
New language elements | 324 | ||
New IDE facilities | 325 | ||
Summary | 325 | ||
Exercises | 325 | ||
Answers to Self-Test Questions | 326 | ||
Console programs | 328 | ||
Introduction | 328 | ||
A first console program | 329 | ||
The command prompt: cd and dir | 330 | ||
The dir command | 331 | ||
The cd command | 332 | ||
Ways of running programs | 332 | ||
Classes in console applications | 333 | ||
Command-line arguments | 334 | ||
Scripting and output redirection | 336 | ||
Scripting and batch files | 337 | ||
Programming principles | 338 | ||
Programming pitfalls | 338 | ||
Grammar spot | 338 | ||
New language elements | 339 | ||
New IDE facilities | 339 | ||
Summary | 339 | ||
Exercises | 339 | ||
Answers to Self-Test Questions | 340 | ||
Object-oriented design | 342 | ||
Introduction | 342 | ||
The design problem | 343 | ||
Identifying objects, methods and properties | 343 | ||
Case study in design | 348 | ||
Looking for reuse | 353 | ||
Composition or inheritance? | 354 | ||
Guidelines for class design | 358 | ||
Summary | 360 | ||
Exercises | 360 | ||
Answers to Self-Test Questions | 362 | ||
Program style | 363 | ||
Introduction | 363 | ||
Program layout | 364 | ||
Comments | 365 | ||
Using constants | 366 | ||
Classes | 367 | ||
Nested Ifs | 368 | ||
Nested loops | 370 | ||
Complex conditions | 372 | ||
Documentation | 373 | ||
Programming pitfalls | 374 | ||
Summary | 374 | ||
Exercises | 374 | ||
Testing | 376 | ||
Introduction | 376 | ||
Program specifications | 377 | ||
Exhaustive testing | 378 | ||
Black box (functional) testing | 378 | ||
White box (structural) testing | 381 | ||
Inspections and walkthroughs | 383 | ||
Stepping through code | 384 | ||
Formal verification | 384 | ||
Incremental development | 384 | ||
Programming principles | 385 | ||
Summary | 385 | ||
Exercises | 386 | ||
Answers to Self-Test Questions | 387 | ||
Interfaces | 390 | ||
Introduction | 390 | ||
Interfaces for design | 390 | ||
Interfaces and interoperability | 393 | ||
Programming principles | 394 | ||
Programming pitfalls | 394 | ||
New language elements | 394 | ||
Summary | 394 | ||
Exercises | 395 | ||
Polymorphism | 396 | ||
Introduction | 396 | ||
Polymorphism in action | 397 | ||
Programming principles | 400 | ||
Programming pitfalls | 401 | ||
New language elements | 401 | ||
Summary | 401 | ||
Exercises | 402 | ||
Databases | 403 | ||
Introduction | 403 | ||
The elements of a database | 403 | ||
The SQL language – introduction | 405 | ||
The VB database classes | 406 | ||
Adding a data connection to Visual Basic | 408 | ||
Example 1: creating a BindingNavigator program | 409 | ||
Example 2: a DataGridView program | 411 | ||
Example 3: SQL example | 414 | ||
Programming principles | 418 | ||
Programming pitfalls | 419 | ||
Grammar spot | 419 | ||
New language elements | 419 | ||
New IDE facilities | 419 | ||
Summary | 419 | ||
Exercises | 420 | ||
Answers to Self-Test Questions | 420 | ||
Appendices | 421 | ||
Selected library components | 421 | ||
Keywords | 427 | ||
Bibliography | 428 | ||
Index | 429 |