Topic: Visual Basic

Beginning Visual Basic 2015 (1119092078) cover image

Beginning Visual Basic 2015

Bryan Newsome
ISBN: 978-1-119-09207-0
Wiley E-Text
624 pages
November 2015
Other Available Formats: Paperback
Electronic Version: US $29.99 Purchase This E-book and Learn More

About This Title  |  Errata  |  P2P Forum for This Title
Table of Contents
INTRODUCTION xxvii

CHAPTER 1: WELCOME TO VISUAL BASIC 2015 1

Implementing Event-Driven Programming 2

Installing Visual Basic 2015 3

The Visual Studio 2015 IDE 5

The Profi le Setup Page 5

The Menu 6

The Toolbars 8

Creating a Simple Application 9

Windows in the Visual Studio 2015 IDE 10

Modifi ed Hungarian Notation 17

The Code Editor 18

Using the Help System 22

Summary 23

CHAPTER 2: THE MICROSOFT .NET FRAMEWORK 25

The .NET Vision 25

This Sounds Like Java 26

Where Now? 27

Writing Software for Windows 27

The .NET Framework Classes 28

Executing Code 30

Common Language Runtime 31

Code Loading and Execution 31

Application Isolation 31

Security 32

Interoperability 33

Exception Handling 33

The Common Type System and Common Language Specification 33

Summary 34

CHAPTER 3: WRITING SOFTWARE 37

Information and Data 37

Algorithms 38

What Is a Programming Language? 39

Working with Variables 40

Comments and Whitespace 43

Comments 43

Whitespace 45

Data Types 45

Working with Numbers 45

Common Integer Math Operations 46

Integer Math Shorthand 49

The Problem with Integer Math 50

Floating-Point Math 50

Working with Strings 53

Using Dates 62

Boolean 69

Storing Variables 69

Binary 69

Bits and Bytes 70

Representing Values 70

Converting Values 72

Methods 74

Why Use Methods? 74

Methods You’ve Already Seen 75

Building a Method 78

Choosing Method Names 81

Scope 82

Summary 84

CHAPTER 4: CONTROLLING THE FLOW 87

Making Decisions 87

The If Statement 88

The Else Statement 90

Allowing Multiple Alternatives with ElseIf 90

Nested If Statements 92

Single-Line If Statement 92

Comparison Operators 92

String Comparison 101

Select Case 102

Case-Insensitive Select Case 106

Multiple Selections 108

The Case Else Statement 109

Different Data Types with Select Case 110

Loops 110

The For...Next Loop 110

The Do...Loop Loops 116

Nested Loops 120

Quitting Early 121

Quitting Do...Loops 123

Infinite Loops 124

Summary 125

CHAPTER 5: WORKING WITH DATA STRUCTURES 127

Understanding Arrays 128

Defining and Using Arrays 128

Using For Each...Next 131

Passing Arrays as Parameters 133

Sorting Arrays 136

Going Backward 137

Initializing Arrays with Values 138

Understanding Enumerations 139

Using Enumerations 140

Determining the State 143

Setting Invalid Values 146

Understanding Constants 146

Using Constants 146

Different Constant Types 148

Structures 148

Building Structures 149

Adding Properties to Structures 152

Working with ArrayLists 153

Using an ArrayList 153

Deleting from an ArrayList 158

Showing Items in the ArrayList 161

Working with Collections 162

Creating CustomerCollection 163

Adding an Item Property 164

Building Lookup Tables with Hashtable 166

Using Hashtables 166

Cleaning Up: Remove, RemoveAt, and Clear 169

Case Sensitivity 172

Advanced Array Manipulation 173

Dynamic Arrays 173

Using Preserve 175

Summary 176

CHAPTER 6: BUILDING WINDOWS APPLICATIONS 179

Responding to Events 180

Counting Characters 184

Counting Words 188

Creating More Complex Applications 191

Creating the Toolbar 192

Creating the Status Bar 195

Creating an Edit Box 196

Clearing the Edit Box 197

Responding to Toolbar Buttons 199

Using Multiple Forms 202

About Dialog 202

Summary 206

CHAPTER 7: DISPLAYING DIALOGS 209

The MessageBox 210

Available Icons for MessageBox 210

Available Buttons for MessageBox 211

Setting the Default Button 211

Miscellaneous Options 212

The Show Method Syntax 212

Example Message Boxes 214

The OpenFileDialog Control 218

The OpenFileDialog Control 218

The Properties of OpenFileDialog 218

OpenFileDialog Methods 220

Using the OpenFileDialog Control 221

The SaveDialog Control 226

The Properties of SaveFileDialog 226

SaveFileDialog Methods 227

Using the SaveFileDialog Control 227

The FontDialog Control 231

The Properties of FontDialog 231

The Methods of FontDialog 232

Using the FontDialog Control 232

The ColorDialog Control 235

The Properties of ColorDialog 236

Using the ColorDialog Control 237

The PrintDialog Control 238

The Properties of PrintDialog 239

Using the PrintDialog Control 240

The PrintDocument Class 240

The Properties of the PrintDocument Class 240

Printing a Document 241

The FolderBrowserDialog Control 248

The Properties of FolderBrowserDialog 248

Using the FolderBrowserDialog Control 249

Summary 252

CHAPTER 8: CREATING MENUS 255

Understanding Menu Features 255

Images 256

Access Keys 256

Shortcut Keys 256

Check Marks 256

The Properties Window 257

Creating Menus 259

Designing the Menus 259

Adding Toolbars and Controls 261

Coding Menus 263

Coding the View Menu and Toolbars 267

Testing Your Code 269

Context Menus 272

Creating Context Menus 272

Enabling and Disabling Menu Items and Toolbar Buttons 275

Summary 279

CHAPTER 9: DEBUGGING AND ERROR HANDLING 283

Major Error Types 284

Syntax Errors 284

Execution Errors 288

Logic Errors 288

Debugging 289

Creating a Sample Project 289

Setting Breakpoints 306

Debugging Using the Watch Window and QuickWatch Dialog Box 313

Debugging with the Autos Window 316

Debugging with the Locals Window 316

Error Handling 318

Using Structured Error Handling 319

Summary 321

CHAPTER 10: BUILDING OBJECTS 325

Understanding Objects 326

Encapsulation 327

Methods and Properties 327

Events 328

Visibility 328

What Is a Class? 329

Building Classes 330

Reusability 330

Designing an Object 332

State 332

Behavior 333

Storing State 333

Real Properties 336

Read/Write Properties 339

Auto-Implemented Properties 342

The IsMoving Method 343

Constructors 345

Inheritance 346

Adding New Methods and Properties 348

Adding a GetPowerToWeightRatio Method 350

Changing Defaults 352

Polymorphism: Scary Word, Simple Concept 354

Overriding More Methods 354

Inheriting from the Object Class 356

Objects and Structures 357

The Framework Classes 357

Namespaces 358

The Imports Statement 360

Creating Your Own Namespace 361

Inheritance in the .NET Framework 364

Summary 365

CHAPTER 11: ADVANCED OBJECT-ORIENTED TECHNIQUES 367

Building a Favorites Viewer 368

Internet Shortcuts and Favorites 368

Using Classes 371

Scanning Favorites 377

Viewing Favorites 384

An Alternative Favorite Viewer 386

Building a Favorites Tray 387

Displaying Favorites 388

Using Shared Properties and Methods 392

Using Shared Properties 392

Using Shared Methods 397

Understanding Object-Oriented Programming and Memory Management 398

Garbage Collection 400

Releasing Resources 400

Defragmentation and Compaction 401

Summary 402

CHAPTER 12: ACCESSING DATA USING STRUCTURED QUERY LANGUAGE 405

What You Need to Complete This Chapter’s Exercises 406

What Is a Database? 407

Database Tables 407

Primary and Foreign Keys 413

Queries 415

Understanding Basic SQL Syntax 415

Using SELECT Statement 416

Using the JOIN Statement 417

Using the UPDATE Statement 419

Using the DELETE Statement 419

Using the INSERT Statement 420

Using the SQL Comment 421

Executing Queries in SQL Server 421

Summary 425

CHAPTER 13: DATABASE PROGRAMMING WITH SQL SERVER AND ADO.NET 427

ADO.NET 428

ADO.NET Data Namespaces 428

The SqlConnection Class 429

Working with the Connection String Parameters 430

Opening and Closing the Connection 431

The SqlCommand Class 431

The SqlDataAdapter Class 434

The DataSet Class 438

DataView 438

The ADO.NET Classes in Action 440

Data Binding 450

BindingContext and CurrencyManager 450

Binding Controls 451

Binding Examples 452

Summary 480

CHAPTER 14: ASP.NET 483

Thin?]Client Architecture 484

Web Forms versus Windows Forms 485

Windows Forms Advantages 485

Web Forms Advantages 485

Web Applications: The Basic Pieces 486

Web Servers 486

Browsers 486

HyperText Markup Language 487

JavaScript 487

Cascading Style Sheets 487

Active Server Pages 488

Benefits of ASP.NET Web Pages 488

Special Website Files 488

Development 489

Controls: The Toolbox 489

Building Websites 490

Creating a Web Form for Client?] and Server?]Side Processing 490

Website Locations with VS 2015 495

Performing Data Entry and Validation 498

Using the GridView to Build a Data?]Driven Web Form 507

Summary 512

CHAPTER 15: DEPLOYING YOUR APPLICATION 515

What Is Deployment? 516

ClickOnce Deployment 516

XCOPY Deployment 521

Visual Studio 2015 Setup Application Options 522

Deploying Different Solutions 522

Private Assemblies 523

Shared Assemblies 523

Deploying Desktop Applications 524

Deploying Web Applications 524

Deploying XML Web Services 524

Useful Tools 525

Summary 525

CHAPTER 16: WINDOWS 8 APPS 529

Windows 8 Application Design Principles 530

Using Touch 530

Application Commands 531

Windows 8 Controls 532

Coding Windows 8 Apps with XAML 533

Creating Your First Windows 8 App 534

Application Layout 548

Application Views 548

Screen Sizes and Orientation 548

Summary 553

APPENDIX: EXERCISE SOLUTIONS 557

INDEX 569