Word Document Properties


Chapter 3: Writing Structured VBA Programs



Download 8,82 Mb.
Pdf ko'rish
bet69/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   65   66   67   68   69   70   71   72   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 3: Writing Structured VBA Programs
08_046500 ch03.qxp 12/5/06 5:34 PM Page 69


Designing procedures
Most of the example programs in this book rely on a single project and a
single module. You might find that most (if not all) of your programs rely on
just one of each of these blocks, too. When using this strategy, think about
how to break your program into sub-procedures and functions. Use the infor-
mation found in the earlier “Using Subs” and “Using Functions” sections in
this chapter to determine which kind of module to use.
The important thing when working at the sub-procedure and function levels
is to write code in convenient chunks. Use your sub-procedures and func-
tions as containers to hold a certain kind of task. Think again about Legos.
Every Lego is an individual unit. You need to write sub-procedures and func-
tions so that you can break them apart easily — making each element an 
individual unit. The examples in this book show you various methods for
breaking your code apart because this skill is one of the most important in
programming.
It’s easy to figure out how to break apart simple code. The 
MsgBox
function
that you’ve used so often is a good example. Look at how this function works:
You send some information to it, and the function takes care of all the details
for displaying the message box onscreen. You don’t have to worry about how
MsgBox
accomplishes this task, and there aren’t any weird conditions for
using 
MsgBox
.
Writing statements
After all the other organization is complete, you’re left with one or more pro-
jects that contain one or more modules that contain at least a sub-procedure.
All your Legos are put together, but they’re empty. The statements that you
write ultimately create the program. All the organization makes the task of
writing the statements easier because you need to concentrate on only one
task at a time.
In Chapter 2, I emphasize the importance of using an organized approach to
writing statements. You begin by creating a pseudo-code procedure, and
then you change that pseudo-code into statements that VBA can understand.
This process provides two levels of organization for your program: code and
documentation. However, there are two other forms of organization. In the
upcoming “Creating Readable Code” section, I describe the importance of using
white space to make your code readable. In the upcoming “Telling Others
about Your Code” section, I show how to use comments to describe how your
code works.
70

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   65   66   67   68   69   70   71   72   ...   207




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish