|
|
 |

 |
|
Practical Standards for Microsoft® Visual Basic® .NET
|
|
|
Author
|
|
James Foxall
|
|
|
Pages
|
496
|
|
Disk
|
N/A
|
|
Level
|
All Levels
|
|
Published
|
07/31/2002
|
|
ISBN
|
9780735613560
|
|
Price
|
$49.99
To see this book's discounted price, select a reseller below.
|
|
|
|
|
 |
|
|
Index
Send feedback about this index to mspindex@microsoft.com.
Symbols
& (ampersands)
assigning access keys, 334
concatenating strings, 79, 85-86, 95
displaying within text of buttons, 334
Object variables and, 78
' (apostrophes) , 128-30
* (asterisks), 125-28
\ (backslashes), 237-38
: (colons)
label captions, 304
multiple statements on single lines, 93-94
. (ellipses), 316
= (equal signs), 102
( ) (parentheses) , 175-76
. (periods), 394
+ (plus signs)
concatenating strings, 85
Object variables, 78, 79
? (question marks), 266
" (quotes), 95
; (semicolons), 238
_ (underscores)
line continuation character, 94-99, 107-8
in value of namespaces, 383
in variable names, 22
A
abbreviations
in comments, 131
of procedure names, 22-23
of variable names, 65, 67-68
About dialog boxes, version numbers displayed in, 398-99
About Face: The Essentials of User Interface Design, 281
accelerator keys. See shortcut keys
accept buttons, 333-34, 381
AcceptButton property, 333-34, 335
access keys. See shortcut keys
accessibility options
keyboard navigation, 330-37
system colors, 323-26
Add Dialog window, 373
Add Existing Project dialog box, 358, 359
Add Files dialog box, 363-64
Add New Item dialog box, 3-5
Add Project Output Group dialog box, 361
Add To SourceSafe Project dialog box, 415, 417
algebraic expressions, 175-76. See also equations
aligning. See also indentation
comments, 132
controls on forms, 380
labels with controls, 303-4
statements, 97-98
alphabetizing procedures, 20-21
Alt key, 321, 334-36. See also shortcut keys
ampersands (&)
assigning access keys, 334
concatenating strings, 79, 85-86, 95
displaying within text of buttons, 334
Object variables and, 78
Anchor property, 294-99
anchoring controls to containers, 294-99, 300
AndAlso and And operators, 166-67
API. See Microsoft Windows API
apostrophes ('), 128-30
Application Folders
adding files to installer, 363-64
custom folders created under, 385
default path of, 365-67, 385
folders listed in, 362, 365
project output added to, 362
side-by-side installation, 399
application programming interface. See Microsoft Windows API
applications, consistency in, 283
argument lists, 213, 219
array variables, 41
arrays, 143
As Object, early binding and, 208
assemblies, 392-96
Assembly object, 10
AssemblyInfo.vb, 395-96
assertions, 246-48, 275
asterisks (*), 125-28
authors identified in comments, 129-30, 134
autoindentation feature, 103-4, 132, 148
Autos window, 260-61, 262
B
backing up files and projects, 404, 417
backslashes (\), 237-38
backward compatibility, 393, 400-402
binary files in Visual SourceSafe, 421
binding objects, 206-9
bit packing, 228-29
blank lines (white space) grouping statements, 111-17
block variables, 82
Boolean operators, 69-70, 166-67, 174-75
bootstrappers, 376, 379, 384
border styles in forms, 284-90
box controls and radio buttons, 310
branching structure, 163. See also flow
Break mode
actions available in, 255
assertions and, 247
debugging windows used in, 255, 261, 266
entering, 247, 254-55, 259
Breakpoint Condition dialog box, 258
Breakpoint Hit Count dialog box, 259
Breakpoint Properties dialog box, 257-59
breakpoints
clearing all, 255
creating and removing, 253
defining conditions for, 257-59
deleting, 256
described, 252-53
disabling, 256, 257
ensuring proper execution using, 276
entering break mode, 247, 254-55, 259
hit count, 257, 259
monitoring in Watch window, 264
Stop statements compared to, 276
Breakpoints window, 255-59
build errors. See compile (build) errors
build numbers, incrementing, 394. See also version numbers
build order, setting, 386-87
business rules, encapsulating, 19
buttons. See also specific buttons and types of buttons
designing, 349-51
hiding and disabling, 304-5
ByRef and ByVal keywords, 26-27
C
CAB files holding install files, 376
Call keyword, 29, 30
call stack, 187-89, 272-73
Call Stack window, 262, 272-73
calling procedures
in Command window, 266
described, 29-30
indenting continuation lines, 101
Windows APIs and, 209
camel casing. See case of letters, mixed-case text
cancel buttons, 333-34, 381
CancelButton property, 333, 335
capitalization. See case of letters
Caption properties, 36
captions in message boxes, 348
case of letters
in comments, 131
in GoTo labels, 51, 178
mixed-case text
in constant names, 51, 52-53
in namespace values, 383
in procedure names, 22
in variable names, 67
Case statements. See also Select Case statements
Case Else statements, 170-71
evaluating numeric values, 172
indentation after, 106-7
ordering sequences for, 171-72
putting multiple result values on single lines, 168
white space surrounding, 113
Catch statements, 184-87, 189
catching exceptions, 184-87
central exception handlers, 190-96
characters. See also specific symbols
case of. See case of letters
identifying authors using, 129-30
maximum per line, 96
check boxes, 313-14, 374
Check In dialog box (Visual SourceSafe), 424-25
Check Out dialog box (Visual SourceSafe), 423-24
class modules, 16
classes
constructors created for, 217-20
file-related, 225-32
finalizers added to, 221-22
forms, 38, 58
naming, 38-39
variables declared Public within, 211
visibility settings, 220
cleanup code, 24, 214, 221. See also garbage collection
Close method, 212, 235-36
closing resources, 212, 235-36
CLR (common language runtime), 206, 238, 399
Code Complete, 91
code flow. See flow
coercion, 73-74, 78, 85
cohesion, 14-16
collapsible code regions, 118-20
Collect method, 223
collections, looping through, 158-61
colons (:)
label captions, 304
multiple statements on single lines, 93-94
color-coding comments, 126
colors in interfaces, 323-26
COM (Component Object Model) technology, 217, 382, 386, 392-93
combo boxes, 310, 312
command buttons. See buttons; specific buttons
command line, setting compiler constants, 251-52
Command window, 265-66
comments
advantages of using, 121-22
described, 121-22
Do loops, 152
end-of-line, 95, 141, 172-74
explaining violations of good programming style, 123-24
formatting
abbreviations, 131
case of letters, 131
denoting using boxes and special characters, 125-29
end-of-line, 173
identifying authors in, 129-30
identifying temporary, 130
indentation, 132
inline, 136-41
procedure comment headers, 133
goals of writing, 122
If statements, white space surrounding, 112-13
in object templates, 11-12
parameters of procedures documented in, 135-36
procedure comment headers, 132-36
purpose of code documented in, 122-23
purpose of procedures documented in, 135
return values of functions documented in, 136
temporary, 130
variable declarations documented in, 141
writing
abbreviations, 131
capitalization, 131
complete sentences, 130-31
editing, 124-25
fitting into comment boxes, 128
procedure comment headers, 132-36
tips for, 122-23
writing code after, 124-25
common language runtime (CLR), 206, 238, 399
compatibility issues, 50, 211, 382, 393, 400-402
compilations
adding debug code, 385-86
conditional. See conditional compilation
Debug.Assert statements removed, 247
incrementing version numbers, 397
compile (build) errors
constructors for classes impacting, 217
described, 179
line continuation character, 95
Option Explicit and, 72
Option Strict and, 54, 80
tasks created from, 268-70
variable declarations and, 73-75
compiler constants, 250-52, 383
Component Object Model (COM) technology, 217, 382, 386, 392-93
components
compatibility when updating, 400-402
giving icons to, 385
installing, 399-400
third-party, verifying version of, 382
compound conditions, 166-67
compressing install files, 376
concatenating strings, 79, 85-86, 95
conditional compilation
checking constants before distribution, 383
DEBUG constant, 276
setting compiler constants, 250-52
writing code for, 248-50
Configuration Manager dialog box, 385-86
configuring setup programs, 376
constants. See also enumerations; specific types of constants
data types, 51-52
declaring, 46, 52-53
described, 45
goals of using, 50
identifying characteristics of, 51-53
literal values compared to, 149-50
loops using, 146
magic numbers compared to, 45-47, 53-54
prefixes, 51-53
scope designators, 52, 53
Step clauses using, 149-50
constructors, 217-20
consuming objects, 215, 217
containers
anchoring controls to, 294-99, 300
docking controls to, 296, 299-301
radio buttons and, 310
tab order and controls, 332
context menus, 337-39, 345
ContextMenu property, 339
continuation lines
indenting, 99-103
line continuation character, 94-99
control boxes, 286
controls. See also specific types of controls
aligning, 380
anchoring to containers, 294-99, 300
confirming password changes, 305-6
disabling and hiding items, 304-5
displaying text and lists, 308-15
docking to containers, 296, 299-301
for labels, 303-4
listed in Properties window, 37
MaxLength property, 336-37
prefixes for, 42-43
regional date and time settings, 301-3
resizing behavior, 294-301
standard appearance, 301-8
Tag property, 306-8
variables differentiated from, 35-36
conversions, widening, 81-82
copyright information in comments, 134
counter variables, 145-46, 150-51
Ctrl key, 321, 428, 429. See also shortcut keys
Cursor property, 339-45
D
/d switch, 252
data
casting, 35-36
displaying for objects associated with current method, 263
edited when calling Debug.Assert, 274-75
hard-coding. See hard-coding
hiding data I/O, 18
hierarchical, displaying, 312-13
obtaining application-specific, 10
passing between procedures, 26-28
printing to the Output window, 267
sharing with object templates, 9
validating, 57-58
data fields, MaxLength property, 336-37
data ink, 126
data tips, 244-45
data types. See also specific data types
of conditional constants, 249
declaring constants as, 51-52
in For Each.Next loops, 160-61
of enumerations, 49
of exceptions, 186
numeric, 73-79
Option Strict and, 35-36, 51-52
specifying for parameters, 26
of variables, 39-41, 73-77, 158-59
widening conversions, 81-82
databases in Visual SourceSafe, 409-13
dates, regional settings, 301-3
DEBUG constant, 276
Debug Location toolbar, 262
Debug.Assert statements, 246-48, 274-75
debugging
breakpoints, 252-59, 276
Catch statements, 189
conditional compilation, 248-52, 276
custom assertion text, 275
defining assertions, 246-48
before distributing solutions, 383
equation problems, 18
expressions editing data, 274-75
fan-in and fan-out affecting, 19-20
goals of, 274
If statements, 112-13
information included in distributed solutions, 385-86
looping structures, 114-15
Option Strict statements, 275
retrieving return values of functions aiding in, 30
speeding up, 17
starting projects without, 274
Stop statements, 276
TODO tasks, 277
viewing expression values using data tips, 244-45
windows useful to
Autos window, 260-61
Call Stack window, 272-73
Command window, 265-66
Locals window, 262
Me window, 263
Memory window, 271-72
Modules window, 271
Output window, 267
QuickWatch window, 264
Task List window, 267-70
Watch window, 263-64
Decimal data type, 75
decision structures. See also specific statements
indentation, 103, 112-13
nested, 172-74
declarations
constants, 46, 52-53
enumerations, 56, 110-11
overriding, 252
variables. See variables, declaring
Declarations sections
constants declared as Private, 52
copyright information in, 134
creating enumerations in, 49
indentation, 110-11
Option Explicit statement, 72-73
placing global constants in, 47
Tag reference explanations in, 307
DefaultLocation property, 370
Delete method, 228, 240
DeleteAtUninstall property, 388
deleting
breakpoints, 256
data, 228
files, confirmation for, 240-41
tasks from Task List, 270
temporary files, 234
dependencies, 387
deterministic finalization, 205
Developing User Interfaces for Microsoft Windows, 281
dialog boxes, designing, 333-34, 373-74, 381. See also specific dialog boxes
DialogResult enumeration, 350
Difference Options dialog box (Visual SourceSafe), 428-30
disabling items, hiding items compared to, 304-5
Dispose method, 212, 214-17, 219
distributing solutions. See also installation; setup programs
adding output of projects, 358-62
aligning controls on forms, 380
assigning root namespace, 382-83
checking conditional compilation constants, 383
checking for accept and cancel buttons, 381
checking for duplicate access keys, 381
checking for exception handlers, 382
checking message box format, 382
giving icons to components, 385
goals of, 380
including debug information, 385-86
preparing projects for, 355-56
proofreading messages in message boxes, 351-52
removing Debug.Assert statements, 247
setting build order, 386-87
setting registry keys, 388
setting SharedLegacy properties of COM files, 386
setting version numbers, 384
setting Vital property, 386
specifying build options of project output, 362-63
spell-checking interfaces, 380
testing and debugging programs, 383
testing tab order, 331, 381
verifying third-party component versions, 382
DLL Hell phenomenon, 386, 392-93
DLLs in Modules window, 271
Do loops
exiting, 154-55
For.Next loops compared to, 152-53
GoTo statements and, 157-58, 177-78
indentation, 107
labeling, 157-58
Until and While used in, 153-54, 155-56
While.EndWhile compared to, 158
Dock property, 299-301
docking controls to containers, 299-301
drop-down menus. See also specific menus
common commands on, 316-20
DropDownStyle property, 312
dynamic lists, 310-12
dynamic text, 309
E
early binding objects, 206-9
edit and continue feature, 244
Edit menu commands, 321, 322
ellipses (.), 316
Else statements, 56, 106
Enabled property, 304
encapsulation, 16, 19-20, 203-4
End menu commands, 317, 318
end value, 144
end-of-construct statements, 104-6, 107, 108. See also specific statements
end-of-line comments, 95, 141, 172-74
Enter key, as accept button, 333, 381
enumerations. See also constants
creating, 28, 49
declarations, 56, 110-11
described, 47-48
displayed in Autos window, 260-61
goals of using, 50
for multiple values, 55-56
numbers in place of values in, 48
referencing names instead of values, 54-55
system color values, 323, 325-26
using, 49-50
validating values passed as enumerated types, 56-58
Windows APIs and, 209
equal signs (=), 102
equations, 18. See also algebraic expressions
error messages. See also exception handling
central exception handlers and, 190-92
logging, 195-96
writing, 198-99
errors. See also specific types of errors
Boolean variable names impacting, 175
breaking statements impacting
Case statements causing, 170
compound conditions impacting, 166
early binding impacting, 208
enumerations impacting, 28, 54
maximum characters in user input fields, 336
reducing time spent locating, 17
variables impacting, 60, 69, 71, 83
Esc key (Escape), 333, 381
Event procedures, 135
events, naming, 38
Exception class, 180
exception handlers
checking for before distribution, 382
described, 190-92
keeping track of objects, 192
logging exceptions, 193-96
types of, 181-82
writing, 182-89
exception handling. See also error messages
anticipated exceptions, 186-87
goals of, 196
nesting, 187-89
Try.Catch.Finally used for, 186-87, 196-97
unexpected exceptions, 196-98
Exception objects, 180, 185
exceptions
anticipated, 186-87
catching, 184-87
logging, 193-96
unexpected, 196-98
exclamation icon, 346
executables in Modules window, 271
exit conditions, 23-24, 154-55
Exit Do statements, 154-55
Exit For statements, 148-49, 152
expressions. See also types of expressions
breaking statements between, 98-99
comparing variety of possible values, 167-72
determining whether false, 246-48
editing data when calling Debug.Assert, 274-75
evaluating, 263-66
formatting for accuracy, 174-76
indenting when broken, 100, 102
viewing values using data tips, 244-45
F
F1 and context-sensitive help, 338
fan-in and fan-out, 19-20
fields, 211. See also specific fields
File menu commands, 321, 322
files
adding to Recent Documents lists, 239-40
closing, 235-36
deleting, confirmation for, 240-41
goals of performing file operations, 232
installation of, 363-65, 371
in My Documents folders, 238-39
names of, 39
paths, 237-38
retrieving properties, 228-29
setting Vital property, 386
System.Environment, 231-32
System.IO, 225-31
temporary, 232-35
in Visual SourceSafe
adding to projects, 425-26
checking in and out, 420-25
comparing revisions, 427-30
getting latest versions, 426-27
removing from control of, 427
finalization, 205, 221-22. See also garbage collection
Finalize method, 221-22
FixedDialog border style, 284-85
FixedSingle border style, 286
FixedToolWindow border style, 288-90
flags for file attributes, 228-29
floating-point values, 261, 262
flow
controlling, 163-64
end-of-line comments affecting, 172-74
formatting expressions for accuracy, 174-76
goals of controlling, 164
GoTo statements affecting, 176-78
If statements affecting, 112, 137, 164-67
indentation illustrating, 91, 107, 147
Select Case statements affecting, 113, 139, 167-72
folders. See also specific folders
displayed in Add New Item dialog box, 4
mapping, 365-67
on target machines during installation, 368-70, 371, 399-400
Visual SourceSafe working folders, 417-19
For.Next loops
counter variables in, 150-51
Do loops compared to, 152-53
exiting (ending prematurely), 148-49, 152
For Each.Next loops, 158-61
GoTo compared to, 157-58
indentation, 147, 151-52
labeling, 157-58
syntax and parameters, 143-49
using constants for step, 149-50
Format menu commands, 322
formatting code. See also writing code
collapsible code regions, 118-20
conditional compilation statements, 248-50
described, 89-92
End If placement, 165
exception handling, 197-98
goals of, 92
grouping related statements, 111-17
importance of, 89-92
indentation
described, 99-103
For.Next loops, 147, 151-52
showing organizational structure, 103-10
showing subordination, 110-11
line continuation character, 94-99
multiple statements on single lines, 93-94
violating good style, 123-24
formatting comments. See comments, formatting
formatting controls. See controls
formatting expressions, 174-76
formatting menus, 316-20
FormBorderStyle property, 284-90
forms
aligning controls on, 380
border styles, 284-90
as classes, 38
making into tool windows, 288-90
morphing, 293-94, 304-5
naming, 39
positions (locations), 291-93
resizing behavior, 286-88, 294-301
sizable borders, 284, 286-88
tab order, 330-33, 381
Friend keyword, 25
friend scope, 25
function keys, 321. See also shortcut keys
Function procedures, 14, 29, 30
functions
on call stack, displaying names of, 272-73
returning values from, 30, 31
specialized, 16-17
G
garbage collection
Close method and, 235
described, 204-5
Dispose methods and, 214-17
Finalize method and, 221-22
forcing, 223
generic implementation, 218-19
GetAttributes method, 228-29
GetTempFileName method, 234-35
GetTempPath method, 233
global constants, 348
global variables
commenting before changing, 140-41
described, 82
disadvantages of using, 83
procedures using, 17, 18
Globally Unique Identifiers (GUIDs), 410
global procedures, 24-25
GoTo statements
alternatives to, 152, 157-58, 176-78
case of letters in labels, 51, 178
disadvantages of using, 22
GUIDs, 410
H
Hand icon, 347
hard-coding
directory separators, 238
numbers. See magic (hard-coded) numbers
paths in applications, 237
values in object templates, 9-11
version numbers, 398-99
Heisenberg uncertainty principle, 274
Help menu commands, 320
hiding items, 304-5
hierarchical information, 312-13. See also lists, displaying
hints provided for forgotten passwords, 305
History Options dialog box (Visual SourceSafe), 427-30
hot keys. See shortcut keys
Hungarian notation, 35, 36-39
I
icons, 346-48, 362, 385. See also specific icons
identifiers (IDs), 206-9
IDs (identifiers), 206-9
If statements
comments before, 137-39
compound conditions, 166-67
conditional compilation, 248-52
indentation, 102-3, 105
Select Case compared to, 56, 167-72
when single conditions are True or False, 164-67
white space surrounding, 112-13
Immediate window, 265-66
indentation. See also aligning
autoindentation feature, 103-4, 132, 148
of comments, 132
of continuation lines, 99-103
Declarations sections, 110-11
of For.Next loop statements, 147, 151-52
showing organizational structure, 103-10
IndexFromPoint method, 345
initializers, 85, 217-18, 220
inline comments, 136-41
Insert menu commands, 319
installation. See also distributing solutions; setup programs
adding files to installer, 363-64
Application Folder path, 365-67, 385
changing file installation properties, 364-65
creating setup programs, 356-58
creating shortcuts, 371
folders on target machines, 368-70, 371, 399-400
including bootstrappers in applications, 384
installing files on desktop, 383
modifying registry during, 371-72
shortcuts created during, 251, 362, 371, 384
side-by-side, 393, 399
specifying uninstall information, 377-78
version numbers ensuring files aren't overwritten, 397
instance counters in constructors, 219
Instancing property, 220
Integer data type, 73-74, 76
IntelliSense drop-down lists, 49-50, 249
interaction, user. See user input and notification
interface design. See also user input and notification; specific interface components
books about, 281
calling objects from interface elements, 206
colors, 323-26
component selection, 308-15
consistency and standardization, 281-83
dates and times, 301-3
disabling and hiding items, 304-5
importance of, 281
label placement, 303-4
password changes, 305-6
setup program interfaces, 373-75
spell-checking before distribution, 380
Tag property, 306-8
K
keyboard navigation and interaction. See also shortcut keys
accept and cancel buttons, 333-34
importance of including, 328-29
MaxLength property, 336-37
tab order, 330-33
L
labels
assigning access keys to controls, 336
GoTo and, 51, 157-58, 178
indenting subordinate code, 108-10
placement of controls, 303-4
text boxes compared to, 309
language and localization, 351
late binding, 207, 362
length
of statements, 94-99
of strings, 86
of text entry fields, 336-37
line continuation character (_), 94-99, 107-8
lists, displaying
check boxes, 313-14
combo boxes, 310, 312
list boxes, 310-11
list view, 311, 313
radio buttons, 309-10
Local Project Items folder, 4, 5
localization and language, 351
Locals window, 261, 262
logging exceptions to text files, 193-96
Long data type, 76
loops. See also specific types of loops
comments before, 140
described, 143
goals of using, 143
nested, 147
white space surrounding, 114-15
M
magic (hard-coded) numbers
loops using, 146
using constants in place of, 45-47, 53-54
validating data by using, 57-58
manifest, 393
mapping of folders, 365-67
mathematic expressions, 175-76. See also equations
Maximize button, 284
MaxLength property, 336-37
McConnell, Steve, 91
Me window, 263
memory
displaying memory dumps, 271-72
garbage collection affecting, 204-5, 223
variables affecting, 60, 73, 79
Memory window, 271-72
menus. See also specific menus and types of menus
access keys and, 335
hiding and disabling items on, 304
importance of, 315
shortcut keys, 320-22
standard format and organization, 316-20
toolbar buttons corresponding to menu items, 322-23
merge modules, 400
message boxes. See also user input and notification
buttons in, 349-51
captions in, 348
checking format before distribution, 382
described, 346
displaying, 47-48
icons in, 346-48
types of, 346-47
writing messages for, 198-99, 351-53
MessageBoxButtons enumeration, 349
MessageBoxDefaultButton enumeration, 349-50
MessageBoxIcon enumeration, 348
MessageBox.Show method, 47-48, 346, 350, 382
metadata, 393
Microsoft .NET wizard format (.vsz), 6
Microsoft Visual Basic, previous editions
Caption properties, 36
command buttons, 43
data tips, 244-45
data types, 76
debugging, 244-48
defining assertions, 246-48
edit and continue feature, 244
environment information, 231-32
error handlers, 180
forms as classes, 38
initializers, 220
nesting, 224
option buttons, 43
Overloads, 213-14
reference counting and garbage collection, 204
version numbers, 396
visibility of classes, 220
Windows API functions, 209-11
Microsoft Visual Basic .NET compiler, 216
Microsoft Visual Basic Project Items, 43
Microsoft Visual SourceSafe
adding new files to projects, 425-26
adding projects to databases, 413-16
adding user accounts to databases, 412-13
checking files in and out, 420-25
comparing revisions, 427-30
components of and tasks performed by, 407-8
creating databases in, 409-10
creating working copies of projects, 419-20
described, 404, 405-6
designating working folders, 417-19
getting latest versions of files, 426-27
installation, 409
opening databases in, 410-11
overwriting changes to files under control of, 427
removing files from control of, 427
Microsoft Visual Studio IDE. See also Visual Basic IDE
debugging in, 246
Microsoft Windows API, 209-11, 239-40
Microsoft Windows Installer technology, 376, 384
Minimize button, 284
mixed-case text. See case of letters, mixed-case text
module-level procedures, 24
module-level variables, 17, 18, 82, 83
modules
alphabetizing procedures in, 20-21
creating, 14-16
definition of, 14
goals of designing, 21
listed in Modules window, 271
naming, 21-23
organization of, 14-16
Modules window, 271
monitor size suggested for viewing code, 96
morphing forms, 293-94, 304-5
mouse interaction
changing cursors, 339-45
importance of including, 328-29
providing context menus, 337-39, 345
MsgBox statement, 329
multiple paths in single string, 238
multiple result values on single line, 168
multiple statements on single line, 93-94
multiple variables declared on single line, 80
multiple-line statements, 97-99, 107-8
My Documents folders, 238-39
N
names and naming
abbreviations used in, 21-22, 65, 67-68
Boolean variables, 174-75
case of characters. See case of letters
constants, 51, 52-53
conventions for, 35-39
hard-coding in object templates, 10
overloading, 37, 213-14
procedures and modules, 21-23, 38
self-documenting code improved by, 36, 37, 122
setup projects, 357, 377, 384
temporary files, 234-35
Visual SourceSafe project files, 410
variables
abbreviations, 65, 67-68
in Boolean variables, 69-70
choosing names, 63-66
mixed-case, 67
overloading, 37
prefixes denoting data type, 38-44
qualifiers used consistently, 68-69
namespace definitions, 38, 382-83
nesting. See also indentation
decision constructs, 172-74
exception handlers, 187-89
indentation, 104-5
loops, 147
readability of code affected by, 92
With statements, 224
.NET Framework objects, 209-11
New Project dialog box, 6-7
Next statements. See For.Next loops
nondeterministic finalization, 205
Not operator, 155-56
notifications, 329-30. See also message boxes; user input and notification
numbers. See magic (hard-coded) numbers
O
Object data types
declarations causing, 26
element variables, 158-59
in For Each.Next loops, 160-61
using only when necessary, 77-80
object templates. See also projects, templates for
adding error handling to, 6
creating, 9
described, 3-5
editing, 5
goals of using, 8
hard-coding values, 9-11
instances added to projects, 4
sharing data from projects, 9
Object variables, 77-80, 208
objects. See also specific types of objects
binding, 206-9
described, 203-4
exposing properties and variables, 211-12
goals of programming, 206
lifetime of, 204
naming, 37
.NET compared to API, 209-11
prefixes for, 41-44
templates created from, 3-5
OK (accept) buttons, 333-34, 381
On Error statements, 180, 181
open paths, storing, 353
Open SourceSafe Database dialog box (Visual SourceSafe), 410-11
option buttons, 169. See also radio buttons
Option Explicit and Option Strict statements
advantages of using, 35-36
build options for projects and, 362
declaring constants as data types, 51-52
declaring variables as object types, 26
described, 80-82
enumerations, 28, 50, 54, 55
explicitly declaring variables, 72-73
implicitly widening conversions, 81-82
late binding and, 207
Option Explicit excluded from, 46
strict typing enforced using, 80-82
turned off, 48
valid values, 57
Options dialog box, 103-4
ordering sequences, 171-72, 186-87
OrElse operator, 166-67
organizational structure, formatting showing, 103-10
Output window, 267
Overflow exceptions, 184, 186
overloading methods, 219
overloading procedures, 213-14, 217
Overloads, 213-14, 219
P
parameters
comment headers documenting, 132-33, 135-36
enumerations and, 55-58
passing data between procedures using, 26-28
sharing data using, 9
validating, 27-28
validating values passed to, 56-58
parentheses ( ), 175-76
passwords
confirming changes to, 305-6
for Visual SourceSafe databases, 412, 413
Path class, 230, 233
paths
Application Folders, 365-67, 385
changing path mapping, 366-67
directory separators in, 237-38
getting from target machines, 237
manipulating using System.IO.Path, 229-31
in object templates, hard-coding, 10
open paths, storing, 353
relative and hard-coded, 237
System.IO.Path used to manipulate, 229-31, 237-38
performance, impacts on
concatenations, 86
early binding, 207-9
Finalize methods, 221
With.End With, 223-24
periods (.), 394
picture boxes, 314
platform independence, 237-38
plus signs (+)
concatenating strings, 85
Object variables, 78, 79
pop-up (context) menus, 337-39, 345
prefixes
for constants, 51-53
for controls, 42-43
conventions for, 36
for objects, 41-44
for Project items, 43
for structures, 40-41
for variable data types, 39-41
for variable scopes, 41, 82-84
for variables, 38-39
private assemblies, 394
Private keyword, 24, 25, 52
procedural variables, 82
procedure headings, 101
procedures. See also specific procedures
adding cleanup code to, 24
adding equations to, 18
alphabetizing in modules, 20-21
calling, 29-30, 101
comment headers for, 132-36
defining scopes, 24-25
definition of, 14
encapsulating business rules in, 19
exit points, 23-24
fan-in and fan-out, 19-20
goals of designing, 21
hiding data I/O in, 18
loosely coupled, 18
modules organizing groups of, 14-16
naming, 21-23, 38
parameters used to pass between, 26-28
return values from functions, 31
scratch variables, 31-32
self-contained, 18-19
sharing data using parameters, 9
with specialized functions, 16-17
tightly coupled, 18
white space surrounding, 117
Program Files folder, 384
Project Dependencies dialog box, 387
Project items, 43
Project menu, 359-62
Project Properties dialog box, 72-73
projects
adding to solutions to be distributed, 358-62
build options for output of, 362-63
object template instances added to, 4
sharing data with object templates, 9
templates created from, 6-7
templates for, 5-8. See also object templates
uninstall information, 377-78
properties. See also specific properties
of breakpoints, 257-59
creating, 211-12
equal to results of expressions, 102
exposing, 11, 211-12
of files, retrieving, 228-29
naming, 38
variables declared Public within (fields), 211
Properties window. See also specific properties
anchoring controls using, 295
controls listed in, 37
customizing shortcuts in, 371
specifying uninstall information, 377-78
Property Pages dialog box
build options in, 362-63
command-line declarations overriding, 252
compilation constants, 250-52
configuration details of setup programs, 376
debug information in distributed solutions, 385-86
property procedures, 11, 14
Protected keyword, 222
public assemblies, 393-94
Public keyword, 24-25, 52, 211
public properties, exposing, 211-12
public variables, 211-12
purpose of code, documenting, 122-23
Q
qualifiers in variable names, 68-69
question marks (?), 266
question-mark icons, 346, 347
QuickWatch window, 264
quotes ("), 95
R
radio buttons, 309-10, 314, 315
readability of code, impacts on
calling procedures, 29
comments, 121-22
constants, 47
eliminating redundancy, 143
formatting, 89-92
grouping related statements, 111-17
indentation, 99-111
line continuation character, 94-99
magic (hard-coded) numbers, 53
multiple statements on single lines, 93-94
naming conventions, 38
nesting, 92
ordering sequences for Case statements, 171
overloading, 213
referencing enumeration member names, 54
retrieving return values of functions, 30
scopes of constants, 52
variable declarations, 80
variable names, 63-66, 67-68
With statements, 223-24
readability of comments. See writing comments
Readme files, 403
read-only fields, 211
read-only files in Visual SourceSafe, 408, 423
ReadOnly keyword, 211
Recent Documents lists, adding files to, 239-40
reentrancy, 83-84
reference-tracing garbage collection, 204-5
referencing
Assembly objects, 10
conditional constants, 249
counting schemes and garbage collection, 204, 205
Dispose method and, 214-17
enumeration members, 49-50
in finalize code, 222
regions of collapsible code, 118-20
registry, 393
registry keys, 371-72, 388. See also Windows registry
relative paths, 237
Release builds, 385-86
REM denoting comments, 128
reserved words, 97
resizing forms, 294-301
resource files in Visual SourceSafe, 416, 421
.resx (resource) files in Visual SourceSafe, 416, 421
retroactive conversion, 329
Return statement, 31
return values. See also values
comment headers including, 132-33, 136
retrieving, 30, 31
revision histories of files in Visual SourceSafe, 427-30
revisions. See version control
right-clicking (context menus), 337-39, 345
root namespace, 382-83
routines, 14
run-time errors, 154, 179-80
S
save paths, 353
saving files, 232-35, 238-39
scaling. See resizing forms
scopes. See also specific types of scopes
of compiler constants, 250
of constants, 52-53
of procedures, 24-25
of variables, 41, 82-84
scratch variables, 31-32
screen space, using efficiently, 286, 288, 310, 312
scroll bars, 309, 314-15
Select Case statements. See also Case statements
Case Else and, 170-71
determining option button selections, 169
determining radio button selections, 310
Else clauses and, 56
If statements, 56, 167-72
indentation after, 106
multiple result values on Case lines, 168
placing comments before, 139
validating values, 58
white space surrounding, 113
SelectedIndex method, 345
self-documenting code, impacts on
calling procedures, 29-30
Case Else statements, 170
comments, 122-23
formatting code, 92
naming conventions, 36, 37, 122
prefixes, 41
semicolons (;), 238
setup programs. See also installation
building, 379
creating, 356-58
editing user interface of, 373-75
naming, 357, 377, 384
specifying configuration details, 376
setup projects
adding files to installer, 363-64
changing file installation properties in, 364-65
changing folders in which files are installed, 371
changing path mapping, 366-67
creating shortcuts for files, 371
editing user interface of setup program, 373-75
modifying registry, 371-72
setting build order, 386-87
working with folders on the target machine, 368-70
SharedLegacy property (COM files), 386
Shift key, 321. See also shortcut keys
Short data type, 76
short-circuiting compound conditions, 166-67
shortcut keys
assigning, 320-22, 334-36
for common menu commands, 317-20
consistency in, 283
duplicate, 381
shortcut (context) menus, 337-39, 345
Shortcut property, 320
shortcuts created during installation, 251, 362, 371, 384
Sizable and SizableToolWindow border styles, 286-90
size. See resizing forms
Smart indenting option, 103-4
solid-character comment lines, 125-27
Solution Explorer window
accessing registry settings, 371-72
adding output of projects to setup programs, 358-60
assigning root namespace, 382-83
changing path mapping, 366
debug information, 385-86
editing user interfaces, 373-75
setting build order, 387
specifying configuration details, 376
viewing and editing build options in, 362
Visual SourceSafe projects in, 415-16, 423, 424, 426-27
solution files in project templates, 8
solutions, distributing. See distributing solutions
source code. See also Microsoft Visual SourceSafe
adding to the Visual SourceSafe databases, 413-16
maintaining versions of, 404
team development and, 406-7
SourceSafe. See Microsoft Visual SourceSafe
spaces
in constant declarations, 252
indenting continuation lines using, 100
in value of namespaces, 383
in variable names, 22
speed, improving
data types for variables, 73
Object variables and, 79
ordering sequences for Case statements, 171
spelling errors in strings, 98
StartPosition property, 291-93
statements
grouping, 111-17
length of, 94-99
multiple statements on single lines, 93-94
multiple-line, 97-99, 107-8
subordinate to line labels, 108-10
static lists, 310-14
static text, 309
static variables, 41, 83-84
status messages, displaying, 267
Step clause, 144-45, 149-50
Stop icon, 346-47
Stop statements, 259, 276
storing
open and save paths, 353
project templates, 6
values, bit packing, 228-29
String data types, 78-79
String.Concat(), 86
strings
concatenating, 79, 85-86, 95
determining whether empty, 86
hard-coding, 45
multiple-line, breaking, 97-98
quotes enclosing, 95
strong cohesion, 14-16
structure declarations, 110
structures, 40-41
Sub procedures, 14, 29, 30
subordination, 108-11
symbols. See specific symbols
syntax errors in strings, 98
SystemDrawing.SystemColors, 323, 325-26
System.Environment, 231-32
System.IO class, 225-31
System.IO.Directory, 226-29
System.IO.File, 226-29
System.IO.Path, 229-31, 237-38
T
tab order, 330-33, 381
TabIndex and TabStop properties, 331-33
tabs. See indentation
Tag property, 306-8
Task List window, 11-12, 267-70
tasks, 11-12, 130, 268-70, 277
team development
source code control, 406-7
version control, 391-404
Template folder, 5
templates. See object templates; projects, templates for
temporary comments, 130
temporary files, 232-35
temporary variables, 65-66
Terminate events, 214, 221
testing programs before distribution, 383
text
copying in Visual SourceSafe, 429
in dialog boxes, 373
editable, 308-9
in label captions, 304
in message boxes, 348, 351-53
text boxes, 308-9, 337
text files, logging exceptions to, 193-96
Text property, 316, 317
third-party components, 382
Threads window, 262
three-fingered salute, 343
tiling behavior, 299
time, regional settings, 301-3
TODO tasks, 11-12, 130, 277
tool window border styles, 288-90
toolbar items, 322-23
Tools menu commands, 319, 322
track bars, 314-15
tree views, 312-13, 374
True or False conditions
Boolean expressions compared to, 174
Case statements producing, 172
If statements and, 164-67
variable names and, 69-70
Try statements
GoTo statements replaced by, 177
handling exceptions
anticipated, 186-87
unexpected, 196-97
nesting, 181, 187-89
On Error compared to, 180
placement of, 180
variable declaration in, 181, 182
Tufte, Edward, 126
U
UDTs (user-defined data types), 40
underscores (_)
line continuation character, 94-99, 107-8
in value of namespaces, 383
in variable names, 22
unfocused variables, 60
uninstalling, 377-78, 386
Until keyword, 153-54, 155-56
updates. See version control
updating magic numbers, 46-47
upgrades. See version control
uppercase. See case of letters
user accounts, adding to Visual SourceSafe databases, 412-13
user input and notification. See also interface design
accept and cancel buttons, 333-34
access keys, 334-36
custom cursors, 339-45
described, 328-30
goals when handling, 330
message boxes, 346-53
notifications, 329-30. See also message boxes
providing context menus, 337-39, 345
saving files in My Documents folders, 238-39
setting MaxLength property, 336-37
setting tab order, 330-33
storing open and save paths, 353
user-defined data types (UDTs), 40
users
confirmation for deleting files, 240-41
confirmation for password changes, 305-6
editing color schemes, 323-26
negative reactions of, 380
Recent Documents lists, 239-40
regional date and time settings, 301-3
V
validating data
fields, 211
magic (hard-coded) numbers, 45-47
parameters, 27-28
Select Case and, 56, 167-72
values passed as enumerated types, 56-58
values. See also data
comparing non-Boolean to variety of, 167-72
enumerations, 28, 55-58
floating-point, 261, 262
hard-coding in object templates, 9-11
in Locals window, 262
returning from functions, 31. See also return values
storing, bit packing, 228-29
track bars indicating, 314-15
viewing, 244-45
in Watch window, 264
variables. See also specific types of variables
in Autos window, 260-61
concatenating, 85-86
controls differentiated from, 35-36
data types, 39-41
declaring
in classes, 211
data types, 73-77, 79
early binding and, 207-9
end-of-line comments documenting, 141
explicitly, 46, 71-73
Hungarian notation and, 37
incorrect names of constants, 46
initializers and, 85
multiple on single lines, 80
scopes, 82, 83
as specific object types, 26
in Try blocks, 181, 182
white space surrounding blocks of, 115
defining purposes of, 60-63
described, 59
determining whether empty, 86
equaling results of expressions, 102
focused, 60-63
goals of using appropriately, 59
holding structures, 40-41
in Locals window, 262
loops using, 146-47, 158-60
naming. See names and naming, variables
Option Strict, 80-82
procedures using, 17
public, exposing, 211-12
scope of, 41, 82-84
set to values, indentation, 100
unfocused, 60
using initializers, 85
in Watch window, 263-64
Variants, 80. See also Object variables
.vb (form class) files in Visual SourceSafe, 421
.vbproj files. See Microsoft Visual SourceSafe
version compatibility, 400-402
version control
assemblies, 392-96
backing up files, 404
compatibility when updating components, 400-402
component installation, 399-400
goals of, 396
maintaining versions of source code, 404
Readme files documenting changes, 403
revision histories of files in Visual SourceSafe, 427-30
tracking versions in team development environments, 406
version numbers
displaying in About dialog boxes, 398-99
entering into AssemblyInfo.vb, 395-96
hard-coding in object templates, 10
incrementing, 394-95, 397
setting, 384
viewing in Windows Explorer, 397
View menu commands, 318, 322
visibility settings for classes, 220
Visible property, 304
Visual Basic. See Microsoft Visual Basic, previous editions
Visual Basic extension for object files, 39
Visual Basic IDE. See also Microsoft Visual Studio IDE
checking files in and out of Visual Basic SourceSafe using, 422-25
displaying user interface layout, 373
getting latest version of Visual SourceSafe files, 426-27
run-time errors in, 180
Visual Basic Projects folder, templates appearing in, 6-7
Visual Display of Quantitative Information, The, 126
Visual SourceSafe. See Microsoft Visual SourceSafe
Visual SourceSafe Explorer
checking files in and out, 420-22, 423, 424
creating working copies of projects, 419-20
designating working folders, 417-19
getting latest versions of files, 426-27
.vsz format, 6
W
warning icon, 346
Watch window, 263-64
weak cohesion, 15
Web Setup Project, 357
While keyword, 153, 154, 155-56
While loops, 158
white space (blank lines) grouping statements, 111-17
widening conversions, 81-82
Window menu commands, 319
Windows API. See Microsoft Windows API
Windows Interface Guidelines for Software Design, The, 281
Windows registry, 393. See also registry keys
windows useful to debugging. See debugging, windows useful to
With statements, 108, 223-24
WriteLine method, 267
writing code. See also formatting code
loops eliminating redundancy, 143
writing comments first, 124-25
writing comments. See comments, writing
writing error messages, 198-99
X
x used as variable name, 64
Y
y used as variable name, 64
yellow arrows next to break statements, 254
Z
z used as variable name, 64
z-order, 299
Last Updated: August 5, 2002
|