Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet157/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   153   154   155   156   157   158   159   160   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part III: Expanding Your VBA Horizons 
14_046500 ch08.qxp 12/5/06 5:36 PM Page 186


Property construction methods
VBA provides three kinds of construction methods for properties. You can
choose to use one or all three methods. A property requires at least one of
the methods described in this list:
Let
:
The 
Let
method helps you set the value of a property. Use it when
the property has a standard data type as an input value.
Set
:
Use the 
Set
method when you create objects that contain other
objects. For example, a 
FileSystemObject
contains 
Drive
objects.
To access these objects, you must use the 
Set
method and not the 
Let
method.
When creating an object within an object, you’re essentially creating a
pointer to a location in memory; but unlike in C or other low-level lan-
guages, the location isn’t important. Within the referenced object are
properties that hold values that affect the operation of the object. You
don’t care how the object works with the property. All you know is that
if you set the 
Caption
property of a control, you’ll see that text dis-
played somehow onscreen. Other properties work the same way —
they affect the operation of the object in some documented way. The
property is yet another kind of indirect pointer, so you need some way
to dereference that pointer and work with the data that it points to.
That’s where 
Let
and 
Get
come into play. Use 
Let
to set a property in
a referenced object to a specific value. Use 
Get
to obtain the value of a
property within the referenced object.
Get
:
The 
Get
method returns the stored property value to the caller.
The method that you use for objects is different from other data types,
but you can return any property value by using this method.
When you create a property, you decide not only the name and data type,
but also its accessibility. The accessibility is read only (using the 
Get
method), write only (using the 
Set
or 
Let
method), or read/write (using
the
Get
method along with the 
Set
or 
Let
method).
Properties have scope, just like everything else in VBA. Besides 
Public
and
Private
, a property can also have a special 
Friend
scope. The 
Friend
scope is a step between 
Public
and 
Private
. Everything within the current
project can see the property, but nothing outside the current project can.
The 
Friend
scope is useful for local configuration. Any part of the local 
project — the part of the program that controls the functionality of the 
object — can configure the property, but your other projects can’t see it.
You can also add the 
Static
keyword to properties. Always add the 
Static
keyword when you want the property to maintain its value between calls but
not when you want to make sure that the property resets to the default value.
The 
Static
keyword is important when you want the object to maintain its
settings.
187

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   153   154   155   156   157   158   159   160   ...   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