Directory listing of http: uap.unnes.ac.id ebook biblebook Visual Basic 6 com & Library Books

5

C H A P T E R

Introducing
Visual Basic









In This Cha pter

I

n this c hapter, I’m go ing to disc uss why yo u sho uld be
using Visual Basic to develo p yo ur database applic atio ns.

Then I’m go ing to quic kly review the types o f Visual Basic
applic atio ns.

W hy use
Visual Basic?
Visual Basic editio ns
Types o f Visual Basic
applicatio ns

Why Use Visual Basic?
The easy answer to this questio n is that Visual Basic o ffers
the best c o mbinatio n o f features, effic ienc y, ease o f use, and
reliability o f any pro gramming language o n the market to day.
Ho wever, the easy answer isn’t always the o bvio us answer, so
let’s lo o k at why yo u sho uld be using Visual Basic fo r yo ur
database applic atio ns.

Basic history
Visual Basic is Mic ro so ft’s latest implementatio n o f a language
kno wn as BASIC (Beginners All-purpo se Symbo lic Instruc tio n

Co de) that was develo ped at Dartmo uth Co llege in 1964. It
was designed to be an easy to use pro gramming language fo r
teac hing students ho w to use a c o mputer.

Jurassic BASIC
In the 1960’s and 1970’s, versio ns o f BASIC were written fo r
nearly every c o mputer platfo rm available, inc luding everything fro m large-sc ale IBM mainframes and Cray superc o mputers to the smallest mini-c o mputers. It was extremely po pular
o n the small mini-c o mputers o f that time, bec ause bo th the
c o mputers and BASIC were interac tive.
Mo st pro gramming languages at that time were c o mpiled in
batc h. In o ther wo rds, yo u entered a bunc h o f statements into










78

Part I ✦ Database Programming Fundamentals

the c o mputer and ran a c o mpiler that c hec ked the syntax and then ran the pro gram
if there were no syntax erro rs. Mo st o ften, yo u had to punc h the statements o nto
punc h c ards using a spec ial devic e kno wn as a keypunc h. Onc e yo u had c reated a
dec k o f c ards with yo ur pro gram o n them, yo u had to submit the c ards using a c ard
reader to a fac eless mainframe c o mputer fo r exec uting. Yo u then had to wait fo r the
c o mputer to run yo ur batc h jo b, at whic h time yo u go t a printo ut that listed yo ur
erro rs. If yo u made a syntax erro r in the first line o f the pro gram, yo u go t do zens o f
pages o f erro rs, whic h had to be fixed befo re yo u c o uld try again. If yo u were luc ky,
yo u c o uld get two o r three runs an ho ur, and if yo u were a lo usy typist, yo u might
spend several ho urs befo re yo u go t far eno ugh to ac tually run yo ur pro gram fo r the
first time.
The key to BASIC’s suc c ess was that BASIC wo uld c hec k eac h line o f c o de when it
was entered into the c o mputer and repo rt any erro rs immediately. This helped
mo st pro grammers find their syntax erro rs and c o rrec t them befo re they tried to
run the pro gram. Then when the pro grammers were ready to run the pro gram,
they sat in fro nt o f a terminal and were able to immediately interac t with the pro gram. This helped immensely when testing a pro gram, bec ause yo u c o uld test yo ur

pro gram, find an erro r, and retest it in a matter o f a minute o r two , whic h allo wed
yo u to get meaningful results muc h quic ker.
Of c o urse this effic ienc y c ame with a c o st. Mo st BASIC pro grams ran very slo wly
when c o mpared to pro grams written in o ther pro gramming languages. Fo r the
mo st part, this meant that the BASICs o f that time were used mo stly fo r teac hing
students ho w to pro gram. After learning BASIC, mo st peo ple wo uld mo ve o nto real
languages like COBOL o r FORTRAN, whic h were mo re suited to building c o mplex
pro grams. This is where BASIC go t a reputatio n fo r being a to y pro gramming language that wasn’t suitable fo r serio us wo rk.

BASIC jumps out of the Gates
In 1976, a small c o mpany kno wn as MITS develo ped a c o mputer fro m a handful o f
elec tro nic parts, inc luding a general-purpo se c alc ulato r c hip fro m a small, littlekno wn c o mpany kno wn as Intel. This c o mputer was kno wn as the Altair 8800.
Ho wever, witho ut a pro gramming language, this c o mputer was pretty useless. It
did, ho wever, pro vide an o ppo rtunity fo r a c o uple o f Harvard students named Bill
Gates and Paul Allen, who fo rmed a c o mpany kno wn as Mic ro so ft. Their first pro duc t was a BASIC interpreter fo r the Altair that ran in 4,096 bytes o f memo ry.
As o ther perso nal c o mputers — suc h as the Apple II, the Co mmo do re, the Atari,
and a ho st o f lo ng-fo rgo tten o thers — were designed, Mic ro so ft was c alled upo n to
develo p versio ns o f BASIC fo r them as well. Befo re lo ng, Mic ro so ft was the standard o f the industry, and every c o mpany that intro duc ed a c o mputer needed a
Mic ro so ft BASIC interpreter.


Chapter 5 ✦ Introducing Visual Basic

When IBM c ho se to enter the perso nal c o mputer marketplac e, they asked Mic ro so ft
to c reate a BASIC interpreter fo r their new mac hine. When disc ussio ns with ano ther
c o mpany fo r an o perating system fell thro ugh, Mic ro so ft was asked to c reate an
o perating system fo r the new c o mputer also . This new o perating system bec ame
kno wn as PC-DOS, and later as MS-DOS.
By no w Mic ro so ft’s BASIC had gro wn to the po int where many peo ple were using it
to develo p serio us applic atio ns. The ability to read and write rando m files was a
standard feature o f the language, tho ugh the c o nc ept o f database ac c ess was years
away. BASIC had bec o me a key pro duc t fo r the suc c ess o f Mic ro so ft and this generatio n o f the perso nal c o mputer industry.

Before BASIC was Visual
Over time, Mic ro so ft realized that a c o mpiler was nec essary to impro ve perfo rmanc e o f BASIC pro grams, so a new pro duc t kno wn as Quic kBasic was c reated.
Ano ther versio n c alled the Pro fessio nal Develo pment System was c reated fo r pro fessio nal applic atio n develo pers and inc luded a number o f to o ls to make their life
easier.
When Mic ro so ft b egan b uilding Windo ws, they dec ided to standardize o n the C
pro gramming language. In o rder to b uild a serio us pro gram in the early versio ns
o f Windo ws, yo u really had to use C b ec ause that was the o nly prac tic al way to
ac c ess the o perating system func tio ns.

Mic ro so ft didn’t fo rget its ro o ts, ho wever, and c reated a spec ial versio n o f BASIC fo r
Windo ws kno wn as Visual Basic . It allo wed pro grammers to inc lude graphic al interfac es fo r their BASIC applic atio ns. Versio n 1.0 o f Visual Basic was the first and o nly
versio n o f Visual Basic to run o n bo th DOS and Windo ws.

Data basics
Mic ro so ft Ac c ess was develo ped to c o mpete with similar pro duc ts fro m Bo rland
c alled Parado x, as well as pro duc ts fro m Ashto n-Tate c alled DBase. These pro duc ts
allo wed peo ple to build simple database applic atio ns quic kly and easily. This was
po ssible bec ause o f the func tio ns pro vided by the databases that were at the heart
o f these to o ls.
Ac c ess c ame with a database kno wn as Mic ro so ft Jet. Unlike the databases used in
the o ther to o ls, Jet was a true relatio nal database. Sinc e Jet was independent o f
Ac c ess, it was po ssible to use it in o ther pro gramming languages. When Visual
Basic 3 was released in 1993, it inc luded an enhanc ed versio n o f the Jet database,
kno wn as Jet 1.1. This to o l bec ame very po pular with develo pers, and there are
so me peo ple that are still using the o riginal Visual Basic 3/ Jet 1.1 c o mbinatio n to
develo p applic atio ns.

79


80

Part I ✦ Database Programming Fundamentals

As time marc hed o n, Mic ro so ft released Visual Basic 4, whic h was the first versio n
o f Visual Basic to suppo rt 32-bit applic atio n develo pment. It was also the last versio n o f Visual Basic to suppo rt 16-bit applic atio n develo pment. This dual nature
was ac c o mplished by two independent implementatio ns o f Visual Basic . Ho wever,
the two versio ns were slightly inc o mpatible with eac h o ther, bec ause so me o f the
c o ntro ls weren’t available in bo th versio ns. This usually c aused a pro blem bec ause
Visual Basic 3 pro grammers c o uldn’t mo ve up to the 32-bit Visual Basic 4 c o mpiler.
Ano ther differenc e between the 16 and 32-bit versio n o f Visual Basic was the Jet 2.5
and Jet 3.0 databases. Jet 2.5 was an impro ved versio n o f the 16-bit Jet database
inc luded with Visual Basic 3, while the Jet 3.5 database was the same 32-bit
database used by Ac c ess 95.
In Visual Basic 5, the 16-bit versio n was dro pped, but numero us enhanc ements
were made to the 32-bit versio n. The biggest enhanc ement was the ability to c reate
yo ur o wn Ac tiveX c o ntro ls. Previo usly, if yo u wanted to c reate yo ur o wn c o ntro ls,
yo u needed to write them in C++, whic h was time-c o nsuming and c o mplic ated and
o ften beyo nd the ability o f the average Visual Basic pro grammer. Ho wever, with
Visual Basic 5, anyo ne familiar with Visual Basic c lass o bjec ts c o uld c reate their

o wn c o ntro ls.
The key to making Ac tiveX c o ntro ls feasible was a native-mo de c o mpiler. Previo us
versio ns o f Visual Basic c o mpiled their pro grams into an intermediate c o de, whic h
was exec uted at runtime by a spec ial interpreter. The new native-mo de c o mpiler
used c o mpo nents fro m the Visual C++ c o mpiler to c reate the ac tual c o de. No w
Visual Basic applic atio ns were almo st as fast as Visual C++ applic atio ns.

BASIC today
Visual Basic 6 is the mo st rec ent versio n o f Visual Basic . I like to think o f Visual
Basic 6 as Visual Basic 5 with every available fac to ry o ptio n. While a few mino r
c hanges were made to the language itself, mo st o f the c hanges added new features
to the develo pment enviro nment. While Visual Basic 5 had o nly o ne type o f applic atio n, Visual Basic 6 adds spec ialized applic atio ns that run o n a Web server ( IIS
Applic atio n) and an applic atio n that runs o n a Web bro wser ( DHTML Applic atio n) .
Also , Visual Basic 6 inc ludes a number o f enhanc ements in the database area.
These enhanc ements inc lude the ability to drag and dro p database definitio ns
o nto a fo rm, a sto red pro c edure debugger, and the ability to design databases
direc tly in Visual Basic .

Database integration
The inc lusio n o f the Jet database in Visual Basic do esn’t nec essarily mean that it’s

easy to use. Ho wever, the engineers at Mic ro so ft wo rked hard to integrate database
suppo rt into the Visual Basic language. This is ac c o mplished thro ugh a few key

Chapter 5 ✦ Introducing Visual Basic

features, suc h as a database o bjec t mo del, the ability to bind regular c o ntro ls to the
results o f a database request, and spec ialized database c o ntro ls.

Database object model
One o f Visual Basic ’s strengths is the ability to c reate and use o bjec ts. Mic ro so ft
to o k advantage o f this ability and c reated a set o f o bjec ts that yo u c an use to ac c ess
the database. This iso lates all o f the lo w-level details fro m the average applic atio n
and makes it easier to use the database.
Visual Basic c urrently suppo rts three different o bjec t mo dels:

✦ Data Ac c ess Objec ts (DAO)
✦ Remo te Data Objec ts (RDO)
✦ Ac tiveX Data Objec ts (ADO)
DAO was o riginally released in Visual Basic 3 to suppo rt the Jet database and its
design reflec ts that. While yo u c o uld use DAO to ac c ess o ther databases, yo u had

to define the o ther databases to Jet and ac c ess them thro ugh Jet. This extra o verhead made a big impac t o n perfo rmanc e.
RDO was develo ped to eliminate the o verhead and allo w pro grammers to direc tly
c o nnec t to SQL Server databases. The RDO o bjec t mo del was also muc h simpler
than the DAO o bjec t mo del, making it easier to use. RDO was first intro duc ed with
Visual Basic 5.
Sinc e neither DAO no r RDO o ffered a universal so lutio n to database ac c ess,
Mic ro so ft develo ped the ADO o bjec t mo del with the intent to make it wo rk everywhere. ADO was first shipped with Visual Basic 6, tho ugh yo u c o uld do wnlo ad a
c o py fro m the Internet fo r use with Visual Basic 5. The ADO o bjec t mo del is similar
to the RDO o bjec t mo del; ho wever, so me o f the restric tio ns impo sed by the RDO
o bjec t mo del were remo ved, making it mo re flexible and easy to use.
CrossReference

Part III of this book is dedicated to the topic of ADO.

Bound controls
Mo st o f the c o ntro ls in Visual Basic c an be tied to an o pen database, and auto matic ally display the info rmatio n in the c urrent ro w o f a table. The user c an alter the
c o ntents o f the bo und c o ntro l and the info rmatio n will auto matic ally be saved into
the database. Using bo und c o ntro ls reduc es the amo unt o f c o de needed to display
info rmatio n fro m a database. And in general, the less c o de a pro grammer has to
write, the mo re stable the pro gram.


81

82

Part I ✦ Database Programming Fundamentals

Database-oriented tools
Visual Basic 6 no w inc ludes a set o f to o ls that helps the pro grammer perfo rm
database func tio ns:

✦ Data Environment Designer helps yo u drag and dro p database design info rmatio n o nto a fo rm to quic kly c reate database applic atio ns.

✦ Data View Window is available to view the c o ntents o f a database table o r
query at design time.

✦ SQL Editor is also available to help yo u c reate and debug sto red pro c edures.
✦ T-SQL Debugger helps yo u debug sto red pro c edures in SQL Server and
Orac le8i systems.

✦ Data Reporter helps yo u build repo rts using info rmatio n fro m the Data
Enviro nment Designer.
The Visual Datab ase To o ls integrated into Visual Basic , allo wing yo u to c reate
and mo dify datab ase struc tures witho ut leaving the Visual Basic develo pment
enviro nment.

Database-oriented controls
Visual Basic also inc ludes several c o ntro ls that are designed primarily with
database ac c ess in mind. The Data Co ntro l (whic h is available fo r bo th ADO and
DAO) allo ws yo u to quic kly build an applic atio n, whic h c an sc ro ll thro ugh the values in a database table o r ac c ess the results o f a database query.
Mic ro so ft also to o k so me c o mmo n c o ntro ls, suc h as the Co mbo Bo x and ListBo x, and
c reated database-spec ific versio ns o f them with enhanc ed func tio ns. These c o ntro ls
take their data direc tly fro m the database rather than requiring the pro grammer to
lo ad them explic itly. Mic ro so ft also c reated a spec ial c o ntro l that allo ws a pro grammer to po pulate a spreadsheet grid with data fro m a database and allo ws the user to
direc tly edit the values. These c o ntro ls are available fo r bo th the ADO o bjec t
libraries and the DAO o bjec t library.
A spec ial c o ntro l kno wn as the DataRepeater c o ntro l takes yo ur c usto m Ac tiveX
c o ntro l, whic h displays info rmatio n fro m a single ro w in a table, and repeats it as
many times as nec essary to display the results o f a database query.

Visual Basic Editions
There are several different editio ns o f Visual Basic that o ffer vario us features
targeted at several audienc es:

✦ Learning Editio n
✦ Pro fessio nal Editio n

Chapter 5 ✦ Introducing Visual Basic

✦ Enterprise Editio n
✦ Other flavo rs o f Visual Basic
Tip

Fixes before the fact: Like m ost softw are today, Visual Basic isn’t perfect. Since
Visual Basic w as first released, Microsoft has found and fixed several problem s
and put the fixes together in a service pack. The service pack can be dow nloaded
from Microsoft’s Web site at www.Microsoft.com/Vbasic by follow ing the
links to product updates and dow nloads. There, you w ill be able to dow nload the
service pack. While hardly any of these problem s should affect you, it is a good
idea to dow nload and apply the service pack to prevent any know n problem s
from happening.

Learning Edition
The Visual Basic Learning Editio n is targeted at peo ple who want to learn ho w to
use Visual Basic . Only the mo st c o re features are fo und in this editio n. While yo u
c an develo p simple database applic atio ns using this editio n, the lac k o f features will
fo rc e yo u to upgrade to the Pro fessio nal Editio n rather quic kly.

Professional Edition
The Pro fessio nal Editio n is the mo st c o mmo n editio n o f Visual Basic . This editio n
inc ludes suc h features at the Data Enviro nment Designer, the Data View Windo w,
whic h allo ws yo u to view the info rmatio n fo und in a database table while designing
yo ur applic atio n, the spec ial database c o ntro ls desc ribed abo ve. The Visual
Database To o ls and the SQL Edito r desc ribed abo ve are inc luded o nly with the
Enterprise Editio n.
Tip

Tools, tools and more tools: In general, I prefer to use the tools found w ith the
particular database system , rather than the Visual Database Tools. This is because
the Database Tools are m issing certain features that w ould eventually force you to
learn the tools included w ith the database system anyw ay.

A full set o f Ac tiveX to o ls are inc luded in the Pro fessio nal Editio n that perfo rm a
wide range o f func tio ns useful fo r building yo ur database, suc h as the TreeView
and ListView c o ntro ls, as well as to o ls that allo w yo ur pro grams to ac c ess
reso urc es o ver the Internet.
Yo u c an c ho o se to b uild a numb er o f different types o f pro grams with the Pro fessio nal Editio n. Yo u c an c reate yo ur o wn Ac tiveX c o ntro ls, yo ur o wn Ac tiveX
o b jec ts, Web server applic atio ns and Web b ro wser applic atio ns in additio n to the
no rmal exec utab le pro grams. This editio n also has a numb er o f wizards that help
yo u b uild applic atio ns mo re q uic kly, as well as a numb er o f templates that yo u
c an easily mo dify to perfo rm ro utine func tio ns.

83

84

Part I ✦ Database Programming Fundamentals

Enterprise Edition
The Enterprise Editio n o f Visual Basic inc ludes all o f the features fo und in the
Pro fessio nal Editio n, but adds the Visual Database To o ls and the SQL Edito r to c reate sto red pro c edures. A number o f o ther fac ilities, suc h as the Visual Co mpo nent
Manager and Visual So urc eSafe, are inc luded to fac ilitate gro up-pro gramming pro jec ts. An applic atio n Perfo rmanc e Explo rer to o l is also available to help yo u determine the effic ienc y o f yo ur applic atio n.
The o ther big differenc e between the Pro fessio nal Editio n and the Enterprise
Editio n o f Visual Basic are the c o llec tio n o f to o ls that are inc luded with the pac kage. Perso nal versio ns o f Internet Info rmatio n Server, and Mic ro so ft Transac tio n
Server and SQL Server are inc luded to help develo pers set up a test enviro nment
o n their o wn c o mputers.
Also , the Remo te Data Ob jec ts are availab le o nly with the Enterprise Editio n. This
was true with Visual Basic 5 as well as Visual Basic 6, b ut is o nly impo rtant if yo u
had o lder pro grams that used RDO. Otherwise, this really isn’t that c ritic al o f a
feature.

Other Variations
Mic ro so ft is so stro ngly c o mmitted to Visual Basic that they find ways to inc o rpo rate it into many pro duc ts, o ften witho ut yo ur kno wledge. Besides the editio ns o f
Visual Basic that I’ve just intro duc ed, yo u c an find additio nal variatio ns in many
o ther plac es.

Visual Basic for Applications (VBA)
Mo st Offic e pro duc ts inc lude a pro duc t kno wn as Visual Basic fo r Applic atio ns
(VBA). This pro duc t is based o n the same Visual Basic language that is used to
develo p applic atio n pro grams. The primary purpo se o f this variatio n is to help
Offic e users build mac ro s that make a partic ular applic atio n easier to use. The
mac ro s are really just c alls to the o bjec t mo del expo sed by the applic atio n itself.
Ho wever, an applic atio n pro grammer c an use this o bjec t mo del to c reate so me
rather c o mplex pro grams that c an be run fro m Wo rd o r Exc el.

Visual Basic Script (VBScript)
Ano ther variatio n o f Visual Basic is kno wn as Visual Basic Sc ript o r VBSc ript.
VBSc ript is designed as a lightweight mac ro language. Many o f the features fo und
in regular Visual Basic and VBA are missing fro m this language. VBSc ript was o riginally implemented as part o f Internet Explo rer as an alternative to JavaSc ript;
ho wever, it c an b e inc o rpo rated into yo ur o wn applic atio n pro grams as well.

Chapter 5 ✦ Introducing Visual Basic

Caution

VBScript and viruses: Recently, several different viruses that w ere w ritten using
VBScript have m ade the new s. These viruses w ere included in e-m ail m essages as
m acros, w hich are autom atically executed w hen som eone opens the m essage.
Just because VBScript is now associated w ith viruses doesn’t m ean that it’s bad,
but you should take appropriate precautions and treat all files that you receive
from e-m ail or otherw ise as a potential virus source.

Windows Host Scripting (WHS)
The final variatio n o f Visual Basic is really a variant o f VBSc ript, kno wn as Windo ws
Ho st Sc ripting (WHS). WHS is used as a mac ro language fo r Windo ws itself. It allo ws
yo u to build c o mplex c o mmand line pro grams similar to tho se built by Unix pro grammers using c sh o r o ther Unix c o mmand interpreters. The best way to think o f
WHS is that it is really just a replac ement fo r the o ld batc h file pro c edures that peo ple used to write fo r DOS.

Types of Visual Basic Programs
There are fo ur main types o f Visual Basic pro grams:

✦ Standard EXEs
✦ Ac tiveX Co ntro ls/ DLLs/ EXEs
✦ IIS Applic atio ns
✦ DHTML Applic atio ns
Many applic atio ns will use a c o mbinatio n o f these pro gram types in o rder to fully
explo it the po wer o f Visual Basic .

Standard EXEs
Peo ple have been building standard EXE applic atio ns fo r years. In this type o f applic atio n, the pro grammer c reates an EXE file that is run by the applic atio n’s user,
whic h in turn interac ts with the user to perfo rm a spec ific func tio n.
When b uilding datab ase applic atio ns, I o ften refer to the standard EXE as the traditio nal c lient/ server pro gram, b ec ause it c o mmunic ates with a datab ase server
using the c lient/ server applic atio n mo del. This helps to distinguish this type o f
pro gram fro m o ther Web -b ased applic atio n pro grams, suc h as IIS Applic atio ns
and DHTML Applic atio ns and o ther multi-tier applic atio ns b uilt using Ac tiveX
c o mpo nents.

85

86

Part I ✦ Database Programming Fundamentals

ActiveX DLLs/ Controls/ EXEs
Ac tiveX pro grams c o me in three flavo rs:

✦ Ac tiveX DLLs
✦ Ac tiveX Co ntro ls
✦ Ac tiveX EXEs
Eac h o f these flavo rs represents a c o llec tio n o f Co mpo nent Objec t Mo del (COM)
o bjec ts that have been c o mpiled and c an be used by o ther pro grams.

ActiveX DLLs
Ac tiveX DLLs are simply a c o llec tio n o f COM o bjec ts that c an be used by o ther pro grams. Sinc e the o bjec ts are sto red in a Dynamic Link Library (DLL), yo u need to
c reate a pro gram that c an use them. They c an’t be used standalo ne. Ho wever,
Ac tiveX DLLs are a great plac e to lo c ate c o mmo n elements that wo uld be shared
amo ng multiple pro grams.
COM+ Applic atio ns are really just Ac tiveX DLL pro grams that have been designed to
run under c o ntro l o f the Windo ws 2000 COM+ Transac tio n Server. The primary purpo se o f COM+ transac tio ns is to c reate a middle tier o f pro c essing that is independent o f bo th the c lient c o mputer and the database server. While yo u c an ac c o mplish
this by using an Ac tiveX EXE, the COM+ Transac tio n Server is far mo re sc alable and
reliable and c an be extremely useful if yo u have a large applic atio n with a high vo lume o f ac tivity.
Note

M TS + 1 = COM + : The COM+ Transaction Server is a m ajor update to the old
Microsoft Transaction Server version 2.0. While m any of the features are sim ilar,
COM+ handles m ore of the details, m aking it easier to use than MTS.

ActiveX Controls
Ac tiveX Co ntro ls are nearly identic al to Ac tiveX DLLs, exc ept an Ac tiveX Co ntro l
pro vides a visual presenc e o n a Visual Basic fo rm. Yo u design an Ac tiveX Co ntro l by
drawing a series o f c o ntro ls o nto a fo rm-like surfac e and adding the c o de nec essary
to manage the c o ntro l.
Ac tiveX Co ntro ls are useful mo stly when yo u want to put a c o mb inatio n o f o ther
c o ntro ls and ac c ess them as a single unit. When c o mb ined with the DataRepeater
c o ntro l, yo u c an display multiple ro ws o f info rmatio n o n a fo rm using the same
fo rmat.

Chapter 5 ✦ Introducing Visual Basic

ActiveX EXEs
An Ac tiveX EXE c o mbines the features o f a Standard EXE with the o bjec ts fo und in
an Ac tiveX DLL. Many pro grams yo u are familiar with are really implemented as an
Ac tiveX EXE, suc h as Mic ro so ft Wo rd and Exc el.
One advantage o f an Ac tiveX EXE is that yo u c an plac e the pro gram o n o ne c o mputer and ac c ess the o bjec ts managed by the pro gram fro m ano ther pro gram running o n a different c o mputer o n the netwo rk. This pro gram c an o fflo ad wo rk fro m
bo th yo ur database server and yo ur c lient c o mputer by adding a middle o r third
tier o f pro c essing.

IIS Applications
In to day’s wo rld, many peo ple are mo ving away fro m traditio nal c lient/ server
database applic atio ns to Web-based applic atio ns. These applic atio ns are really just
pro grams that run o n the Web server that return a string o f HTML tags in respo nse
to a request fro m the Web bro wser.
An IIS Applicatio n is a spec ial type o f Visual Basic pro gram that do esn’t have any
graphic al c o mpo nents. Instead, it rec eives requests that o riginate fro m a Web
bro wser via the same o bjec t mo del used by Ac tive Server Pro grams (ASP) c reated
by Visual Interdev. Then, the IIS Applic atio n c o nstruc ts a Web page and returns it
bac k to the Web bro wser fo r further pro c essing by the user.
Sinc e the IIS Applic atio n impo ses very few requirements o n the Web bro wser, it
do esn’t matter if the user has Internet Explo rer, Netsc ape Navigato r, o r nearly any
o ther type o f Web bro wser running o n any type o f c o mputer. This is the o nly type o f
Visual Basic pro gram that will run o n a Mac into sh o r a Sun wo rkstatio n. Ho wever,
as its name implies, IIS Applic atio ns will o nly wo rk with an IIS Web server, so yo u
must have a Windo ws 2000/ NT server to run yo ur IIS Applic atio n.

DHTM L Applications
A DHTML Applicatio n is a Web page that c o ntains an embedded Ac tiveX DLL, whic h
c an c o mmunic ate with a database server o r ac c ess o ther reso urc es o ver the Internet.
Its primary advantage is that it do esn’t invo lve the Web server o nc e the Web page
and DLL have been do wnlo aded. Ho wever, DHTML Applic atio ns o nly run o n Internet
Explo rer 4.01 o r higher.

87

88

Part I ✦ Database Programming Fundamentals

Thoughts on Visual Basic
Microsoft claim s that over three m illion people program in som e form of Visual Basic. While
this num ber undoubtedly includes people w ho w rite m acros in Word and Excel, the true
num ber of real Visual Basic program m ers still exceeds one m illion individuals. I’m proud to
be one of them .
I’ve been creating program s for over 25 years. I’ve used traditional program m ing languages
like Fortran, COBOL, and Pascal for years. I’ve used specialized languages such as LISP,
Prolog, GASP and SAS. I’ve used m ore assem bly and system s program m ing languages than
I can rem em ber. I even used C before there w as a C+ + . I’ve w ritten com pilers for m y ow n
program m ing languages, w hich w ere used by no one but m yself. Yet I prefer Visual Basic to
all of them .
There are m any reasons w hy I prefer Visual Basic, but the m ost im portant one is that I’m
m ore productive in Visual Basic than any other language, especially w hen w riting Window s
program s. I can start w ith nothing and end up w ith a com prehensive program faster in
Visual Basic than any other language.
I w ouldn’t use Visual Basic to build a com piler, nor w ould I use Visual Basic to w rite an
operating system , but I w ould use Visual Basic to w rite nearly any other type of program .
And w hen it com es to database program s, Visual Basic is a clear w inner to m e. It is easy to
create both traditional client/ server and Web-based database program s, and by using
ActiveX DLLs and COM+ transactions, you can gain a great deal of flexibility in how you
actually create these program s.

Summary
In this c hapter yo u learned that:

✦ Mic ro so ft’s first c o mmerc ial pro duc t was an implementatio n o f a pro gramming language c alled BASIC.

✦ Visual Basic c o mes in multiple editio ns, o f whic h o nly the Pro fessio nal Editio n
and the Enterprise Editio n have c o mplete database suppo rt.

✦ Yo u c an c reate standard EXEs, Ac tiveX Co ntro ls, Ac tiveX DLLs and Ac tiveX
EXEs using Visual Basic .

✦ Yo u c an develo p Web server-based Visual Basic applic atio ns using IIS
Applic atio ns.

✦ Yo u c an develo p bro wser-based Visual Basic applic atio ns using DHTML
Applic atio ns.

✦ Yo u c an develo p Visual Basic to build n-tier applic atio ns using COM+
transac tio ns.