Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet75/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   71   72   73   74   75   76   77   78   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
08_046500 ch03.qxp 12/5/06 5:34 PM Page 76


Notice that 
MyGlobalVariable
is private. You can’t access this global vari-
able outside the current module. However, both of the sub-procedures in this
module can access the global variable.
As another example, 
GlobalTest
is a public 
Sub
, but 
GlobalTest2
is pri-
vate. To verify the use of scope in this case, open the Macro dialog box by
using the Tools

Macro

Macros command. You see 
GlobalTest
listed, but
GlobalTest2
doesn’t appear in the list.
Type and run the example code in Listing 3-4 to see how the two 
Sub
elements
affect each other. You should see three dialog boxes. The first dialog box
reads 
Hello
because 
GlobalTest
sets the value of 
MyGlobalVariable
.
The second dialog box also reads 
Hello
because 
MyGlobalVariable
is
truly global. Even though the value of this variable was set in 
GlobalTest
,
GlobalTest2
can read it. Finally, the third dialog box reads 
Goodbye
because 
GlobalTest2
has set 
MyGlobalVariable
to another value.
Creating Readable Code
You might have noticed how the examples in this chapter use white space to
make the code more readable. If you type all the statements for your program
one right after the other, the code still works. VBA doesn’t care about white
space. However, you might care because code without white space is nearly
unreadable.
Most VBA users rely on two kinds of white space. You’ve seen the first type in
this chapter. Notice that every comment and statement pair in the code is fol-
lowed by a blank line. This blank line tells anyone reading the code that he
has reached the end of this particular statement or step in the procedure.
The second kind of white space is indention. The examples in this chapter
indent the code within a 
Sub
or 
Function
to make the body of the 
Sub
or
Function
clear.
Telling Others about Your Code
The pseudo-code technique that I describe in Chapter 2 is a good way to start
documenting your code. However, at some point, you need to add informa-
tion because simply reading the procedure presented by the pseudo-code
might not be enough. You might want to add your name, a project title, and
other forms of documentation to your code.
77

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   71   72   73   74   75   76   77   78   ...   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