Overview
It can be very difficult to pick up a new skill, especially when the
training material starts off assuming you know more than you actually do!
Throughout my tutorials I will continually try to put things into perspective
and to explain why a certain capability of VB is valuable and whether it
might be valuable to you. This means that my introductions to each of the
sections will be a bit long, but the intent is to set the stage so that you
will know why you need to know the information in that section. To begin,
let's talk about VB and how it was derived from its predecessor, BASIC.
A Definition
Visual Basic is a much-enhanced version of the BASIC programming language and
the BASIC Integrated Development Environment (IDE). The bottom line of the
enhancement is the VB can create Windows programs whereas BASIC could only
create DOS programs. Ok, so the modifications are very major, but the
idea holds true that Visual Basic is BASIC for Windows.
One of the many significant improvements is that VB provides massive support
for easily creating the user interface to your applications. This is
accomplished within the VB Integrated Development Environment (IDE), in which
you use a mouse to "draw" your application and use the keyboard to type
in the code that is to be executed. When I write a VB program, I almost
always create the user interface "shell" before I write any code at all. This
approach, made so simple by the VB IDE, allows me to evaluate how the user
will interact with the program. I can generally create the initial version
of the shell in just hours. It's a much better way to program than to
create pieces of the interface (and the corresponding code) as you go. It
especially is beneficial in that you can demonstrate to the users just
exactly what they will see, and you can do it early enough in the development
cycle to prevent costly reiterations later in the cycle.
The single largest effect on coding that VB introduced was the concept of an
event-driven programming model. In the old BASIC you had to write code to
watch for the occurrence of user events (pressing a key, using the mouse,
...). VB performs that function for you, and in fact, the only
time code will execute in VB is in response to such an event!
And finally, the other major concept that VB has incorporated is the
concept of objects. Objects provides a way to link together both
code and data into a "package" in such a way as to make handling and saving
the code/data more intuitively. VB forms are objects, menus are objects, and
the so are the intrinsic VB controls. A lot more on this later!
VB has also provided a wide variety of built-in code that programmers once
had to handle themselves. Of most significance is the built-in database
handling features of VB. It is generally accepted that over half of all
VB applications are written to handle databases! You'll find the built-in
database features of VB to be very powerful, and that you can tap into
them at whatever level of programming skill you possess.
A second area in which VB has begun to provide built-in support is that of
Internet access. The VB features are still maturing, but with the tools
available you can create very useful applications. I've included Internet
topics in the Advanced section of the tutorial because it is such a specialty
application, not so much because its concepts cannot be handled by less
skilled programmers. Feel free to skip around in the tutorial if you find
a section that interests you.
Critical Visual Basic Elements
Although Visual Basic has grown into a fairly complex programmming tool,
it is still the case that a programmer can pretty much ignore all of the
capabilities he doesn't need (or understand) and still create very useful
applications.
But, no matter how much a beginner, or how advanced you are, there are still
some fundamental areas in which you must be proficient to become a VB
programmer.
When you start VB, you will see a group of windows that are know as the
VB IDE (integrated development environment). As a programmer you will spend
the majority of you time here, so you might as well get used to the IDE
and spend a fair amount of time exploring the menu options that the IDE
provides. Pay closed attention to the keyboard shortcuts that are available.
If you've read my other Beginner sections you'll know that I am a big
fan of the keyboard and have argued that the #1 productivity tool you have
is good typing skills. While in the IDE, you'll find the keyboard shortcuts
invaluable in writing your program quickly.
The second aspect of VB which programmers of all skill levels will have in
common is the VB language itself. Most of the questions I get through email
are
focussed on "how do I ..." and the answer is almost always couched in terms
of the code that it takes to perform the task. If ever there was less boring
reading than the VB language reference manual, I don't know what it is, but
it also provides one of the biggest payoffs of studying that I can
recommend. At least 90% of every question I answer for visitors to my
site is in the manual!
Every Visual Basic application will consist of controls, usually a lot of
them! In my opinion, the availability of
controls (built-in, or controls you can purchase) is the single biggest
reason why VB has reached the level of popularity that it currently
enjoys. Because controls represent hundreds (if not thousands) of hours
of manpower to come up with full-featured, debugged code which you can resuse
in your program, controls are easily the most cost-effective, and
the most time-effective way that a VB programmer has to add features to his
program. Bottom line is that any good programmer must be an expert at
handling controls. In my experience, once you've mastered the intrinsic
controls, learning new controls becomes very straightforward.
Because VB has moved to the event-driven model of programming, the last
critical VB topic I will mention is that of events. Events are not very
complicated
but the concept is significantly different than the old-style linear
programming of the original BASIC. Simply put, when a VB program is started
it sits and waits for an event to occur. The event can be a keypress by
the user or the movement of a mouse. Either way, the VB programming model is
that your program will only react to events. When an events occurs, VB will
execute the code associated with that event. So your job as a programmer
is to basically create the code which your program executes in response to
those events.
Programming Basics
To toss in a bit of philosophy, I view a programmer's job as getting to
the end product with a minimum of effort. When you're paid by the hour you
have an obligation to your employer (even if it's yourself) to minimize the
cost/schedule of completing the assignment. To that end, I will emphasize
over and over again the importance of using existing capabilities (such
as your own reusable code, VB-provided controls, or even controls that you
purchase).
In light of this optimize-your-time philosophy, I also believe that every
VB programmer should strive
to become an expert in the following two areas: Databases and Reporting.
It's very common for applications to store data and to provide that data in
a printed format (by some estimates, 80% of all VB applications use
databases). And while this tutorial will discuss various ways to
perform these tasks, most programmers will find that the capabilities of
VB for creating/editing Access (a Microsoft product) databases and VB's
capabilities for reporting that data (as exemplified by the Crystal Reports
control or the newer built-in VB reporting features) are the most effective
tools you can use for increasing your effectiveness in creating VB
applications.
If you want to become a serious VB programmer, you must become an
expert in these areas. I'm not saying that Microsoft's built-in tools are
the only, or best, tools available for creating/editing databases and
reporting on them. What I am saying is that tools which provide similar
functions will be one of the most commonly used tools of those available to
a programmer and that any serious programmer must take the time to develop
strong skills with these tools.
One by-product programming strategy of my philosophy is that newbies should
not get too anxious to jump into the more advanced features of VB. Take the
time to learn the basics, and especially how to apply them with ingenuity.
Once you've exhausted the potential of the fundamentals is the
time to consider more advanced techniques. In my experience, over 90% of
my programs consists of fundamental programming techniques, while only
rarely am I compelled to dip into the more complex features that VB has to
offer.
VB History (VB3, VB4, VB5 and VB6)
Starting with VB5, Visual Basic became an exclusively 32-bit programming
language, suitable for programming only Win9X or NT systems. If you must
program
for Win 3.x, then you'll have to drop back to either VB3 or VB4, both of
which are in pretty short supply. VB4 had the dual ability to support
Win3.x as well as Win9X/NT systems but my personal recommendation is that
if you need 32-bit system support, go straight to VB6 and if 16-bit is your
need then stick with VB3.
The VB Learning Edition is the most affordable, and truth is that you can
do a lot with it, particularly if you use the Windows API to augment its
capabilities. However, in light of its better database features and its
greater variety of controls, I suggest you go straight to the Professional
Edition if at all possible. The price is steep, but it really does pay
itself back in terms of time savings. If you
need the VB Enterprise edition then you should have it paid for by the
"Enterprise" which requires it. Individual programmers generally do not need
the Enterprise edition.
|