|
These set of tutorials are a bit retro
since VB.NET is deliberately not being covered. Users can find excellent
coverage of VB.NET elsewhere. The tutorial will use the following developer
tools:
Visual Basic 6
Visual Basic for Application 6.x
Visual Studio 97
As promised in our review of Java and Visual Basic, this commences a
series of tutorials on Visual Basic 6 and then later VBA. The tutorials
will be geared to an intermediate level of programming understanding.
Thus, we assume the reader has programmed in at least one other procedural
language - C, Fortran, Pascal, Javascript but not HTML. HTML is a tag
language and does not have flow of control commands like FOR or IF-THEN.
It also is assumed users are reasonably comfortable working in Windows
with a browser( preferably Mozilla) or Word Perfect or Excell or some
other application with a full set of GUI features.
In order to accomodate beginning and advanced users, we have provided
a reading list of books on Visual Basic. In addition we will suggest
additional reading in each tutorial from two of those books - Peter
Wright's Beginning Visual Basic 6 for beginning users and Visual
Basic 6 Black Book for advanced users. Finally, there will be programming
exercises the full code of which will always be available at this website.
Now, without furthur to do, welcome to Visual Basic. |
|

Figure 1- Visual Basic IDE
|
Visual Basic - The Basic Canvas
As we have pointed out in the introduction to these tutorials, Visual Basic and its follow-up, Visual Basic for
Applications (VBA - the scripting language for Microsoft Office Suite and about 100 other major Windows applications)
pioneered and refined visual programming. Visual programming means that you paint the look and feel of your program
and then tie together the forms, controls and overall processing with code and procedural code. The task of making
the visual parts function as an effective whole program is expedited by templates, wizards and design tools within
the Visual Basic IDE-Interactive Development Environ. This is your visual development "canvas".
Figure 1 shows the Visual Basic canvas. This is where you will be working both in VBA and Visual Basic a good percentage
of the time. So it will be worthwhile getting to know these 5 Basic elements very well. As we shall see when we
cover Java next time, this style/usage of multiple windows (called MDI-Multiple Document Interface by Microsoft)
is a very popular IDE.. Most programming development tools have copied this layout to some degree, so learning
it well will pay dividends.
Everytime you load a VB or VBA project, you will be greeted by roughly the layout shown in Figure 1 and these five
GUI tools. First, the toolbox(1) contains all the GUI elements/controls needed to create any VB form
and the front end to all VB programs. For example, after the pointer tool there is the image control,
label, textbox, frame and command button as the first five of 20 standard controls which are used constantly in
VB programs. Another advanatge of these basic controls is that they fill 60-90% of all your programming needs and
are automatically included in the VB runtime. It is possible to add many other Micrsoft supplied or third party
ActiveX components/controls to this toolbox (including your own home-built control); but these added components
can add significantly to the final size of your runtime. We will discuss these issues in detail in a future tutorial.
Second is your form(2). Think of it as yours- you can size it, color it, give it a caption ("Database
Test" in this case) and fill the form with GUI controls which help your program do useful works. Putting controls
on your form is as easy as clicking on the control (say the command button) in the toolbox and then dragging and
sizing it on your form(see the "Exit" button on the form). The exercise at the end of the tutorial builds
up the pictured form.
The third part of the Basic canvas are the menus and toolbars(3) which manage and control all of VB/VBA.
Yes indeed there are lots of commands and operations to learn - Visual basic has sprouted like a weed in the past
three years. Our tutorials will highlight the most important. But most readers will be familiar with many of the
menu and icons. File, Edit, View, Run, Window, Help menus should be familiar to any Word Perfect, Excel, or Netscape
users. Likewise icons for File Open, File Save, Cut, Copy, Paste, Find, Run programs, Pause Program, Halt Program
can be seen along the toolbar. Along with built in wizards and custom command centres in some controls, this is
the heart of VB.
Fourth is the Project Explorer (4)which you use to access all the forms and coding files in your VB program.
The PE-Project Explorer is such a handy navigation device you will find yourself using it all the time to switch
among different forms and code.Yes, even in small to medium-sized programs multiple forms are easy to do and quite
common. The Project Explorer is so important we will spend a session on it and the text editor (not shown above).
Fifth, and even more frequently used than the Project Explorer is the Properties sheet(5). Note that
the "Exit" command button is highlighted in the form and is also the control listed in the Properties
sheet. The Properties sheet is both the elegance and the swamp of VB. If you want to change the property of any
control like its color, shape, caption, or whatever - the Property sheet is the place to go. But a command button
has 32 properties - and some controls have hundreds, hence the swamp. Fortunately, the 80-20 rule applies - for
example, 80 % of operations can be done with 6 properties on the command button - Appearance, Caption, Enabled,
Tooltip, TabIndex, and Visible.
You will find in developing in Visual Basic that you spend a large percentage of time using the Project Explorer
and Property sheet. It is worthwhile to get to know them well. Project Explorer is your means of navigating
around the various parts of VB; while Property sheets allows you to set the very basic look and feel plus behaviour
of all your forms in Visual Basic.
The trick is getting to know the most useful properties, controls and
overall commands quickly.But as detailed in our introductory Java and
Visual Basic, Visual Basic documentation has gone from bad to worse. VB
documentation is fractured, out of date and/or smeared over several manuals.
Those manuals are only available in printed form for considerable extra
cost , and the examples and tutorials are either slimmer or again available
at extra cost. Hence one of the motivations behind these tutorials. VB6/VBAs
quality and pervasiveness deserve better.
So below are a list of 5 book resources we have selected for beginning to advanced users. Two which we shall refer
to during the course of these tutorials are Beginning Visual Basic 6, Peter Wright - Wrox Press and Visual
Basic 6 Black Book by Holzner from Coriolis.
Resources:
Visual Basic 6 in Plain English, Overland - M&T Books, $36 - beginning to intermediate, good intro to a number
of topics
Beginning Visual Basic, Peter Wright - WROX, $56 - beginning with no assumption of programming background
Visual Basic 6 Unleashed, Rob Thayer - Sams $58 - intermediate with comprehensive coverage of features
Visual Basic 6 Black Book, Holzner -Coriolis, $70 - gradually advanced coverage into components, web, database,
etc
Visual Basic 6 Database HowTo, Waite Group - Sams, $57 - devoted to all the complications of VB database tasks |
| Summary of Major Visual Basic Canvas Features |
|
|
1)The toolbox icon - toggles the main toolbox of form controls on and off. |
|
|
2)The form icon in the Project Explorer. Click on this and the active Form will appear in the edit window. |
|
|
3) The toolbar handle. Every toolbar has one. Pull on it to move/reposition the toolbar anywhere on the screen. |
|
|
4)The Project Explorer icon - toggle this to make the Project Explorer appear or disappear. |
|
|
5) Property sheet icon - toggle this to make the Property sheet appear or disappear. |
|
Exercise:
Read Beginning VB6/Wrox chapter 1 and 2 or VB6 Black Book/Coriolis chapter
1 and do the sample programs to get used to the VB IDE elements we introduced
here.
Top of Page Tutorials
Home ©Imagenation 2001-2004
|
|