Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Chapter 1
Visual Basic Overview

Welcome to our big book on Visual Basic. It’s no secret that Visual Basic is the favorite programming environment of many programmers. (In fact, you’re reading a book written by one of those programmers right now.) When Visual Basic first appeared, it created a revolution in Windows programming, and that revolution continues to this day. Never before had Windows programming been so easy—just build the program you want, right before your eyes, and then run it. Visual Basic introduced unheard-of ease to Windows programming and changed programming from a chore to something very fun.

In time, Visual Basic has gotten more complex, as well as more powerful. In this book, we’re going to see how to use Visual Basic in a task-oriented way, which is the best way to write about programming. Instead of superimposing some abstract structure on the material in this book, we’ll organize it the way programmers want it—task by task.

This book assumes you have some familiarity with Visual Basic; when you use this book, you’ll usually have some task in mind—setting a program’s startup form, for example, or optimizing for a specific processor—and this book will provide the answer. We’ll try to be as complete as possible (unlike the frustrating recordings of frequently asked questions—which never seem to address your particular problem—you can access while on hold for tech support). This book is designed to be the one you come back to time and time again. It’s not just to learn new techniques, but it is also to reacquaint yourself with the forgotten details of familiar methods.

We’ll start with an overview of Visual Basic, taking a look at topics common to the material in the rest of the text. In this chapter, we’ll create the foundation we’ll rely on later as we take a look at the basics of Visual Basic, including how to create Visual Basic projects and seeing what’s in such projects. We’ll also get an overview of essential Visual Basic concepts like forms, controls, events, properties, methods, and so on. And we’ll examine the structure of a Visual Basic program, taking a look at variables, variable scope, and modules. In other words, we’re going to lay bare the anatomy of a Visual Basic program here.

We’ll also take a look at programming practices common to all Visual Basic programs. This overview chapter is the place to take a look at those practices because they involve the rest of the book.

Most Visual Basic programmers do not have formal programming training and have to learn a lot of this material the hard way. As programming has matured, programmers have learned more and more about what are called “best practices”—the programming techniques that make robust, easily debugged programs. We’ll take a look at those practices in this chapter, because they are becoming more and more essential for programmers in commercial environments these days, especially those programmers that work in teams. And we’ll look at those practices from the viewpoint of programmers who program for a living; frequently there’s a gap between the way best practices are taught by academics and how they are actually needed by programmers facing the prospect of writing a 20,000-line program as part of a team of programmers.

We’ll start our overview chapter by creating and dissecting a Visual Basic project, jumping right into the code.

Creating A Project In Visual Basic

There are three different editions of Visual Basic:

  The Learning Edition, which is the most basic edition. This edition allows you to write many different types of programs, but lacks a number of tools that the other editions have.
  The Professional Edition, designed for professionals. This edition contains all that the Learning Edition contains and more, such as the capability to write ActiveX controls and documents.
  The Enterprise Edition, which is the most complete Visual Basic edition. This edition is targeted towards professional programmers who may work in a team and includes additional tools such as Visual SourceSafe, a version-control system that coordinates team programming.

We’ll use the Enterprise Edition in this book, so if you have either of the other two editions, we might occasionally use something not supported in your Visual Basic edition. We’ll try to keep such occurrences to a minimum.

Start Visual Basic now, bringing up the New Project dialog box, as shown in Figure 1.1.


Figure 1.1  Creating a new Visual Basic project.

In Figure 1.1 you see some of the project types that Visual Basic supports:

  Standard Windows EXE programs
  ActiveX EXE files
  ActiveX DLLs
  ActiveX controls
  Programs written by the Visual Basic Application Wizard
  Data projects
  IIS (the Microsoft Internet Information Server) applications
  Visual Basic add-ins
  ActiveX document DLLs
  ActiveX document EXE files
  DHTML applications
  VB Enterprise Edition controls

This list of project types indicates some of the ways Visual Basic has grown over the years. As you can see, there’s a whole galaxy of power here (and we’ll cover that galaxy in this book). In this case, we just want to take a look at the basics of a standard Visual Basic project, so double-click the Standard EXE item in the New Project dialog box, opening Visual Basic itself. Figure 1.2 shows the Visual Basic Integrated Development Environment (IDE). (We’re going to cover all parts of the Visual Basic Integrated Development Environment in the next chapter—here, we’ll just use it to create our first project.)


Figure 1.2  A new Visual Basic project.

For our first example, we might create a small tic-tac-toe program using nine buttons in a form, as shown in Figure 1.3.


Figure 1.3  Designing our first project.

When the user clicks a button, we can display an “x” in the button’s caption, as shown in Figure 1.4.


Figure 1.4  Clicking a button in the tic-tac-toe program to display an “x”.

If the user clicks another button, we can display an “o”, and so forth.

This example will create a program that lets us take a look at Visual Basic projects, controls, control arrays, events, properties, coding, variables, and variable scope.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.