Word Document Properties


Chapter 8: Object-Oriented Programming



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

Chapter 8: Object-Oriented Programming
14_046500 ch08.qxp 12/5/06 5:36 PM Page 189


The code for this property is very simple. It simply passes the 
UseHelp
Button
value back and forth. Notice that the comment for the 
Let
method
includes a reference to the 
vbMsgBoxHelpButton
style. (Whenever you con-
vert a function or other real-world entity into an object, try to preserve the
original information in the comments that you write.) This comment helps
you remember that this property replaces the 
vbMsgBoxHelpButton
style.
Property naming considerations
You normally want to use the same names for properties in your object that
other programmers use for their objects. This technique makes it easier for
you to remember the purpose of a property. However, you also want to avoid
confusion. If a property doesn’t provide precisely the same functionality, it’s
better to use a different name. For example, the 
MsgBox
function provides the
vbMsgBoxRight
style to allow flush-right text alignment. You might think that
you should use the 
TextAlign
property found in other objects, such as the
Label
control. However, the 
TextAlign
property allows left, center, and
right text alignment, so using this name for the example could prove confusing
because the 
MsgBox
function doesn’t allow center alignment. The example
uses a 
Boolean
value and a different name for the property, as shown here:
Public Static Property Let RightAlignText(Value As
Boolean)
‘ Should the example use the vbMsgBoxRight style?
UseRightAlignment = Value
End Property
Public Static Property Get RightAlignText() As Boolean
‘ Return the vbMsgBoxRight value.
RightAlignText = UseRightAlignment
End Property
Notice that the property name is very specific. The name makes it clear that
left alignment is the default and that you can only choose right alignment as
an option.
The 
MsgBox Context
argument does precisely match the 
HelpContextID
property used by many existing objects, so the example does use that name
for the property. I ran into a problem with the 
MsgBox Prompt
and 
Title
arguments. Theoretically, both arguments should appear as part of the
Caption
property. When you set the 
Caption
property of a 
UserForm
,
you set the title bar text. Likewise, the 
Caption
property sets the text that
appears in a 
Label
control. The example uses the 
Caption
property for
the
Prompt
argument and uses a 
Title
property for the 
Title
argument.
Because you use the 
Prompt
argument more often, setting it equal to the
Caption
property makes sense.
190

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   155   156   157   158   159   160   161   162   ...   207




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.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