Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet164/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   160   161   162   163   164   165   166   167   ...   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 194


AbortRetryIgnore = 2
YesNoCancel = 3
YesNo = 4
RetryCancel = 5
End Enum
You assign values to each of the constants within the enumeration. The
values don’t have to follow any particular order, and you don’t have to start
with 0. It helps to order the enumeration in some way. The example uses the
help topic order to make it easier to compare the help files with the values
that the code contains. You can also order the entries alphabetically or in
order of usage frequency. When a class uses an enumeration for a particular
value, VBA displays the acceptable values.
Look at the 
MsgObj.Buttons
line of code shown in Listing 8-6. When you
type 
=
at this line, you see a list of acceptable values for that property. The
list contains the acceptable button values for the example. The advantage of
this technique is that you don’t have to remember the individual values, and
the probability of providing an incorrect value drops dramatically. Always
use enumerated constants, when you can, to reduce errors and typing time.
Defining initialization
Every class should provide property and local variable initialization. Adding
initialization ensures that your class won’t fail because of a lack of input. In
addition, initialization can help you create objects with less code because
many of the values are already defined. The 
Class_Initialize
method
performs all the initialization tasks for any class. See Listing 8-5 for the 
initialization code used for the example.
Listing 8-5
Initializing a Class
Private Sub Class_Initialize()
‘ Set the initial prompt.
ThePrompt = “Hello World”
‘ Define a simple title.
TheTitle = “”
‘ Don’t include a default help file or context.
TheHelpFile = “”
TheHelpContext = 0
‘ Initialize the variables.
‘ Use the Information icon.
(continued)
195

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   160   161   162   163   164   165   166   167   ...   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