Sie sind auf Seite 1von 8

vBA Flash Caiu System

Biitton Kowalk
!"#$%&'(# *%++,-.
In my Business Law class this semestei I've been amazeu at the many nuances anu
intiicacies of the legal system. So amazeu, in fact, that I've staiteu getting neivous
about the final test. I've iealizeu that it's going to be a bit of a challenge without
some help. To piepaie, then, I ueciueu to builu a flash caiu system that I can use to
stuuy.

Similai flash caiu systems have been uevelopeu by stuuents in the past (see
http:vbapiojects.blogspot.com2u1u12flash-caiu-machine-biian-baugh.html
foi one example), but these piojects lackeu a few functions that I ieally hopeu foi
like a tiue u0I inteiface, a simple way to biowse anu euit caius, anu ways to hiue
caius that have been amply leaineu.

To fill this neeu, I have uesigneu a fully u0I-baseu flashcaiu system. The
management siue of the application allows auuing, iemoving, anu euiting caius. The
stuuy siue featuies simple contiols to move foiwaiu anu backwaiu thiough caius,
to maik caius as leaineu (which hiues them fiom stuuy), to ieset all caius that have
been hiuuen, anu to uisplay hints the usei has input. As an auuitional challenge, I
auueu the ability to uisplay biief snippets ietiieveu fiom Wikipeuia on any given
teim.


/+01#+#2&,&'32
The application is launcheu by opening its excel uocument:

A seconu tab ("Batabase") can be accesseu if a usei feels the neeu to input uata
uiiectly into the app's back enu uatabase. 0theiwise, clicking the stait button
launches the welcome scieen:

Aftei this point, the piogiamming logic is of gieatei inteiest. We'll now focus on
that. The implementation of the flash caiu system can be bioken uown into two
sections: caiu management anu stuuy.

4,-5 6,2,7#+#2&
If a usei clicks "Euit Caius," they aie piesenteu with the following inteiface:



The inteiface's list of caius is populateu on launch by scanning thiough the (now
hiuuen) uatabase spieausheet. Euit fielus (on the iight) aie populateu whenevei a
usei selects a teim to view. Any changes maue aie wiitten out to the uatabase
spieausheet when the "Save Caiu" button is piesseuall fielus aie ieau anu wiitten
to the iow on the spieausheet that coiiesponus with the selecteu iow in the teim
list on the left.

Piessing the auu button cieates a new iow in the uatabase, uisplays it in the list on
the left, then allows the usei to input infoimation anu save the caiu. The auu caiu
button, fuithei, is uisableu until the usei finishes inputting uata, thus pieventing the
acciuental cieation of multiple, blank caius.:
Removing a caiu acts similailythe iow is iemoveu fiom the uatabase, then
iemoveu fiom the list on the left. While simple, the inteiface is veiy iobust anu
stops the usei fiom seveial uiffeient eiiois. Note how in the save coue below, the
system ensuies that a piopei caiu is selecteu befoie saving, then ensuies that the
usei has changeu the uefault text aftei cieating a caiu.


To ensuie that the inteiface always shows accuiate uata anu shows the caius in an
easily seaichable, alphabetical oiuei, a visual iefiesh subioutine was uesigneu.
Aftei eveiy change, this subioutine iuns anu (1) alphabetizes the uatabase followeu
by (2) iefieshing the uata uisplayeu on the u0I.


The enu iesult is a simple, iobust inteiface foi cieating anu euiting laige sets of
caius.


*&%5.
Enteiing the stuuy poition of the inteiface biings the usei to the following scieen:

0pon launch, a ianuom caiu is selecteu anu its teim uisplayeu (the caiu selection
function will be uesciibeu below). The usei can then use the contiols on the bottom
iight to move foiwaiu (fiist ievealing the uefinition, then moving to the next caiu
selecteu by the caiu selection function), maik the caiu as leaineu (which will wiite a
value to the "hiue" column anu pievent the next caiu function fiom selecting the
caiu until the "ieset caius" button on the left is piesseu) oi go back to the pievious
teim stuuieu.

In the event that the usei neeus a hint, they can simply click on the "hint" button. A
message box is uisplayeu with the hint the usei attacheu to the caiu, which is ieau
fiom the uatabase spieausheet:

If the usei wants fuithei infoimation on the given teim, they can click the Wikipeuia
button to ietiieve a paiagiaph fiom the intiouuction to the teim's Wikipeuia aiticle:

This teim is gatheieu by taking the given teim, tiansfoiming it to loweicase,
changing spaces into unueiscoies, anu attempting to ietiieve a Wikipeuia aiticle
fiom the page http:en.wikipeuia.oigwiki|teim_namej. If the page is founu, the
system then seeks to finu the table of contents on the page. The paiagiaph uiiectly
above the table of contents is ietiieveu as an intiouuction. Bue to wiue vaiiation
between Wikipeuia pages, this paiagiaph befoie the contents section was founu to
be the most ieliable methou of ietiieval.


In all instances of inteiaction with the flash caiu winuow, confiimations anu
instiuctive uialogs help the usei to unueistanu the inteiface bettei. Foi example,
iesetting the caius ieveals the following uialog while the application cleais the
"hiuuen" maikei fiom eveiy caiu iow in the uatabase:

Teims that yielu no Wikipeuia aiticle will uisplay a message of "Soiiyno
Wikipeuia aiticle founu foi this teim". Teims with no hint will ieminu the usei that
they foigot to input a hint. Even the leaineu button helps the usei unueistanu its
function aftei piessing it:

This message is only uisplayeu once in oiuei to stieamline the stuuy piocess.

The flash caiu section piesenteu many challenges in couing. 0ne of these (which
continually piesenteu pioblems) was the subioutine selecting the next caiu. Aftei
many iteiations, the final coue checks the numbei of iows in the uatabase anu
selects a ianuom iow, checks if the iow has a maikei in the "hiue" column (filleu in
when a usei maiks a caiu as leaineu), anu checks if the potential next iow is the
same as the last iow uisplayeu. So long as neithei of these thiow ieu flags, the
ioutine sets the new iow anu allows it to be uisplayeu. If eithei causes pioblems,
the system tiies anothei iow.


What if, howevei, the usei has clickeu "leaineu" on all of theii caius. The system
will catch this when it ieaches its 1uuu
th
tiy to finu a new iow, iealizing then that
the ueck is complete. The usei is then given the following instiuctions:



8'9$%99'32 3: ;#,-2'279 ,25 4<,11#27#9
I've been piogiamming foi some time, so much of the back enu coue of this pioject
was stiaightfoiwaiu. Baving not spent much time in vBA usei foims, howevei, the
gieatest challenge I encounteieu was in cieating a iobust inteiface. 0vei anu ovei, I
founu ways that I coulu bieak my system oi biing about iesults that weien't
uesiiable. I spent a lot of time looking into logic that woulu enable anu uisable
buttons, check input fielus, anu ensuie accuiate ieflections of infoimation fiom the
uatabase. In shoit, my big lesson fiom this pioject was the impoitance of testing.

Foi example, I uiscoveieu that it woulu be simple foi a usei to cieate many
unwanteu iows in the caiu uatabase that, once the system alphabetizes them back
into oiuei, woulu be haiu to finu in a laige caiu set. To pievent useis fiom cieating
lots of new caius without inputting theii infoimation, the auu caiu button is now
uisableu until a new caiu is piopeily input anu saveu.

As one moie example, I fiist piogiammeu my Wikipeuia functionality baseu on the
stiuctuie of just a few pages that I hau come acioss. I founu patteins in them anu
useu these to figuie out wheie the intiouuctoiy paiagiaphs that shoulu be pulleu in
weie founu. Bowevei, I founu ovei time that massive eiiois coulu occui in this
methouthe wiue vaiiation of Wikipeuia pages maue it necessaiy to pull input
fiom only one paiagiaph iathei than all intio paiagiaph (the best uelimiteis
Wikipeuia pioviues at piesent specify the beginning anu enu of the bouy of the
aiticle, but nothing about the stiuctuie beneath that is built by the wiki community).
I ueteimineu that this functionality, even if impeifect, woulu still be quite useful in
many instances, anu completeu anu incluueu it.

Das könnte Ihnen auch gefallen