Preface 11
P.1 The book's conception 13
P.2 Typographic conventions 16
P.3 Where you can find help and further information 17
Part I - Start up!
Getting started with Visual Basic 21
1 Visual Basic, VBA and VBScript 23
1.1 What are Visual Basic, VBA and VBScript? 23
1.2 Programming in Visual Basic 24
1.3 What can Visual Basic do? 25
1.4 The editions of Visual Basic 27
1.5 Service Pack 4 and other updates 27
2 Introduction to VB 29
2.1 Object orientation in VB 29
2.1.1 What is an object? 29
2.1.2 What is a class? 33
2.2 Starting Visual Basic: the different project types 33
2.3 The development environment 35
2.3.1 Overview of the windows 35
2.3.2 Fundamentals of writing program code 38
2.4 The Visual Basic project 42
2.5 Important options 45
2.5.1 Options of the development environment 45
2.5.2 Compiling options 47
2.6 A first Visual Basic application 48
Part II - Take that!
Programming in Visual Basic 55
3 Fundamentals of the VBA language 57
3.1 Modules 57
3.2 Statements, expressions and operators 59
3.3 Declaring variables 67
3.3.1 Implicit declaration 67
3.3.2 Explicit declaration 67
3.4 The data types 72
3.4.1 The VBA data types 73
3.4.2 The Reddik naming convention 78
3.4.3 Static arrays 83
3.4.4 Dynamic arrays 84
3.4.5 Initializing arrays 86
3.4.6 Allocation of arrays 86
3.4.7 Structures 86
3.4.8 Symbolic constants 87
3.4.9 Enumerations (Enums) 88
3.5 Loops and branches 90
3.5.1 Conditional branches 90
3.5.2 "Branch" functions 93
3.5.3 Unconditional branches 94
3.5.4 Loops 94
3.5.5 Exiting a program block 98
3.5.6 The With statement 99
3.6 Procedures and functions 99
3.6.1 Declaring procedures and functions 100
3.6.2 Call by Value and Call by Reference 102
3.6.3 Functions that return objects 103
3.6.4 Functions that return arrays 104
3.6.5 The passing of arrays 104
3.6.6 Parameter arrays 105
3.6.7 Optional arguments 106
3.6.8 Recursion 107
3.7 Conditional compilation 108
3.8 Working with objects 109
3.8.1 Class libraries 112
3.8.2 Collections 113
3.8.3 Your own collections using dictionary objects 114
4 VBA functions and VB objects 121
4.1 The object browser 121
4.2 File and folder functions 123
4.3 String functions 127
4.3.1 Extracting partial strings and shortening strings 127
4.3.2 Compare strings and search for partial strings 127
4.3.3 Replacing strings 131
4.3.4 Conversion and creation of strings 132
4.3.5 Separating and joining strings 133
4.3.6 The left-over Len function 134
4.4 Formatting functions 135
4.5 Date functions 138
4.6 Arithmetic functions 141
4.7 Conversion functions 141
4.8 Information functions 143
4.9 Interaction functions 144
4.10 Functions for output and input 146
4.10.1 The MsgBox function 146
4.10.2 The InputBox function 149
4.11 The VB objects 149
5 Controls and forms 153
5.1 Standard controls, ActiveX and windowless controls 153
5.2 Common elements of all controls 155
5.2.1 The most important common properties 155
5.2.2 Common events 158
5.2.3 Common methods 159
5.3 Standard controls 160
5.3.1 The label 160
5.3.2 The text box 161
5.3.3 The Command button 164
5.3.4 CheckBox and OptionButton 165
5.3.5 The List box 167
5.3.6 The Combo box 171
5.3.7 VScrollBar, HScrollBar 172
5.3.8 FileListBox, DirListBox and DriveListBox 173
5.3.9 The Shape control 174
5.3.10 The Line control 175
5.3.11 The PictureBox and Image control 175
5.3.12 The Timer 177
5.3.13 Arrays and frames 177
5.4 The ActiveX controls 178
5.4.1 The CommonDialog 179
5.4.2 ProgressBar 189
5.4.3 StatusBar 190
5.4.4 ImageList 191
5.4.5 Toolbar 193
5.5 The windowless controls 194
5.6 Dynamic creation of controls 195
5.7 Working with forms 197
5.7.1 Create forms 198
5.7.2 Using forms in the program code 200
5.7.3 Initialize and terminate forms 202
5.7.4 Object-oriented definition of forms 203