Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet73/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   69   70   71   72   73   74   75   76   ...   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 74


The 
GetDocProperty
function introduces several new ideas. The first idea
is a return value. Functions can return a value to the caller. The second idea
is the use of an argument. An 
argument
is input to a 
Sub
or 
Function
. In this
case, 
Name
is the input to the 
GetDocProperty
function.
The actual code within the 
GetDocProperty
function looks the same as the
example in the earlier “Writing Your First Sub” section. However, in this case,
the code uses 
Name
(a variable) as input to 
ActiveWorkbook.Builtin
DocumentProperties
instead of as a constant. Also, notice that the code
makes the function equal to the 
MyProperty.Value
property. This is how
you return a value to the caller.
Getting the Scoop on Scope
You might think that the concept of scope is confusing and difficult to under-
stand because you think that it’s complex. Actually, 
scope
is simply the range
of what a program can see and how much it lets others know. When you look
at the 
MsgBox
function, you care about the inputs that you provide and the
output that the function produces. These are the public (or visible) elements
of the 
MsgBox
function. You don’t care too much about what happens inside
the 
MsgBox
function even though this information is important to the 
MsgBox
function itself. These inner workings — the ones that you can’t see — are the
private (or invisible) elements of the 
MsgBox
function.
There are two reasons that scope is important to you as a VBA user. First, if
every part of a program could see every other part of a program, chaos would
result because there would be too much information to track. Second, programs
have to protect their data to ensure that it doesn’t get damaged in some way.
In short, you want to make some parts of your program visible so that people
can use them, but leave other parts invisible so that they remain protected.
Understanding the purpose of scope
You’ve seen two keywords used for all the 
Sub
and 
Function
examples so
far: 
Public
and 
Private
. These two keywords can affect other elements as
well. You can use them to define the scope of variables or of classes. Scope
has an effect on just about every kind of programming element that you use
in this book, so it’s important to understand how scope works:

Download 8,82 Mb.

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