01_574019 ffirs.qxd 9/16/05 9:31 PM Page x
Contents Acknowledements XVI Introduction XXIX Who is this book For? XXIX What Does This book cover? What Do I Need to run visual basic 2005? Customer Support How to Download the Sample Code for the book XXXII XXXII p2p.wrox.com Why This System Offers the Best Support Chapter 1: Welcome to visual Basic 2005 Windows Versus DOs Programming Installing visual Basic 2005 The visual basic 2005 IDE The Profile Setup Page he toolbars 2367789 Creating a Simple Application Windows in the visual studio 2005 IDE The Toolbox Modified Hungarian Notation The Code editor 18 Using the Help System 23 Exercise Chapter 2: The Microsoft NET Framework Microsoft's reliance on windows MSN 1.0 he, Net Vision This sounds like java Where now? Writing Software for Windows
Contents Acknowledgments xxvii Introduction xxix Who Is This Book For? xxix What Does This Book Cover? xxix What Do I Need to Run Visual Basic 2005? xxx Conventions xxxi Customer Support xxxii How to Download the Sample Code for the Book xxxii Errata xxxii p2p.wrox.com xxxiii Why This System Offers the Best Support xxxiii Chapter 1: Welcome to Visual Basic 2005 1 Windows Versus DOS Programming 2 Installing Visual Basic 2005 3 The Visual Basic 2005 IDE 6 The Profile Setup Page 7 The Menu 7 The Toolbars 8 Creating a Simple Application 9 Windows in the Visual Studio 2005 IDE 10 The Toolbox 13 Modified Hungarian Notation 17 The Code Editor 18 Using the Help System 22 Summary 23 Exercise 23 Chapter 2: The Microsoft .NET Framework 25 Microsoft’s Reliance on Windows 25 MSN 1.0 26 The .NET Vision 27 This Sounds like Java 28 Where Now? 29 Writing Software for Windows 29 02_574019 ftoc.qxd 9/16/05 9:50 PM Page xi
Contents he net framework classes Executing Code Common Language Runtime 33 Code Loading and Execution Application Isolation Security Exception Handling 34 The Common Type System and Common Language Specification Summary 36 Chapter 3: writing software 37 Information and data 37 Algorithms at is a programming language? Variables Comments and whitespace 42 Comments Data Types 44 Working with Numbers Common Integer Math Operations Integer Math Shorthand he Problem with Integer Math Floating-Point Math Other States Single-Precision Floating-Point Numbers orking with Strings Using the Concatenation Operator Inline More String Operations Substrings Formatting Strings Localized Formatting Replacing Substrings Using Dates 60 Formatting Date Strings Extracting Date Properties Date constants Defining Date Literals
xii Contents The .NET Framework Classes 30 Executing Code 31 Common Language Runtime 33 Code Loading and Execution 33 Application Isolation 33 Security 34 Interoperation 34 Exception Handling 34 The Common Type System and Common Language Specification 35 Summary 36 Chapter 3: Writing Software 37 Information and Data 37 Algorithms 38 What Is a Programming Language? 39 Variables 39 Working with Variables 40 Comments and Whitespace 42 Comments 42 White Space 44 Data Types 44 Working with Numbers 44 Common Integer Math Operations 45 Integer Math Shorthand 47 The Problem with Integer Math 48 Floating-Point Math 49 Other States 50 Single-Precision Floating-Point Numbers 50 Working with Strings 51 Concatenation 52 Using the Concatenation Operator Inline 54 More String Operations 55 Substrings 56 Formatting Strings 57 Localized Formatting 58 Replacing Substrings 59 Using Dates 60 Formatting Date Strings 61 Extracting Date Properties 62 Date Constants 63 Defining Date Literals 64 02_574019 ftoc.qxd 9/16/05 9:50 PM Page xii
Conten Manipulating Dates Boolean 56 Storing Variables Bits and Byte Representing Values Converting Values Methods Why Use Methods? Methods You 've Already Seen Building a Method Method Names Exercises Exercise 1 76982288 Chapter 4: Controlling the Flow Making Decisions The if statement he else statement Allowing Multiple Alternatives with Elsel Nested If Statements 8888 Single-Line If Statement Using Not Equal To 89 Using the Numeric Operators More on andand or String Comparison Select case Using Select Case Case-Insensitive select Case Multiple selections Different Data Types with Select Case 108 111 Looping Backwards 112 The For Each... Next Loop 113
xiii Contents Manipulating Dates 65 Boolean 66 Storing Variables 67 Binary 67 Bits and Bytes 68 Representing Values 68 Converting Values 70 Methods 71 Why Use Methods? 72 Methods You’ve Already Seen 72 Building a Method 76 Choosing Method Names 79 Scope 80 Summary 82 Exercises 82 Exercise 1 82 Exercise 2 82 Chapter 4: Controlling the Flow 83 Making Decisions 83 The If Statement 84 The Else Statement 86 Allowing Multiple Alternatives with ElseIf 87 Nested If Statements 88 Single-Line If Statement 88 Comparison Operators 88 Using Not Equal To 89 Using the Numeric Operators 90 The And and Or Operators 93 More on And and Or 97 String Comparison 97 Select Case 99 Using Select Case 100 Case-Insensitive Select Case 103 Multiple Selections 106 The Case Else Statement 107 Different Data Types with Select Case 108 Loops 108 The For . . . Next Loop 109 Step 111 Looping Backwards 112 The For Each . . . Next Loop 113 02_574019 ftoc.qxd 9/16/05 9:50 PM Page xiii
Contents Loop Loops 114 116 Acceptable Expressions for a Do.. Loop 118 other Versions of the Do.. Loop 119 Quitting Early 120 Infinite Loo 123 Summary 124 Exercises 124 Exercise 1 124 124 Chapter 5: Working with Data Structures 125 Understanding Arrays 125 Defining and Using Arrays Passing Arrays as Parameters Sorting Arrays 133 Initializing Arrays with Values 135 Understanding Enumerations 136 Using Enumerations 136 Determining the state Setting Invalid value Understanding Constants Using Constants How It Works 145 Different Constant Types Structures 145 Building Structures 146 Adding Properties to Structures 149 Working with Array Lists Deleting from an ArrayList 153 Showing Items in the array List Working with Collections 157 Creating CustomerCollection ng an Item Property Building Lookup Tables with Hashtable 161
xiv Contents The Do . . . Loop Loops 114 Do While . . . Loop 116 Acceptable Expressions for a Do . . . Loop 118 Other Versions of the Do . . . Loop 118 Nested Loops 119 Quitting Early 120 Quitting Do . . . Loops 122 Infinite Loops 123 Summary 124 Exercises 124 Exercise 1 124 Exercise 2 124 Chapter 5: Working with Data Structures 125 Understanding Arrays 125 Defining and Using Arrays 126 Using For Each . . . Next 128 Passing Arrays as Parameters 130 Sorting Arrays 133 Going Backwards 133 Initializing Arrays with Values 135 Understanding Enumerations 136 Using Enumerations 136 Determining the State 140 Setting Invalid Values 142 Understanding Constants 143 Using Constants 143 How It Works 145 Different Constant Types 145 Structures 145 Building Structures 146 Adding Properties to Structures 149 Working with ArrayLists 149 Using an ArrayList 150 Deleting from an ArrayList 153 Showing Items in the ArrayList 156 Working with Collections 157 Creating CustomerCollection 158 Adding an Item Property 159 Building Lookup Tables with Hashtable 161 02_574019 ftoc.qxd 9/16/05 9:50 PM Page xiv