Word Document Properties


Chapter 8: Object-Oriented Programming



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


Monitoring data change is an important event. You might need to perform
verification or to modify other object settings when a data change occurs.
For example, when you decide to change the button style, you also need
to check the default button setting to ensure that it falls within the desired
range. Listing 8-3 shows a typical example of a data modification event.
Listing 8-3
Creating an Object Event
Public Static Property Let Buttons(Value As ButtonTypes)
‘ Change the value of the message button based on the
‘ input value.
Select Case Value
Case OKOnly
UseButtons = vbOKOnly
Case OKCancel
UseButtons = vbOKCancel
Case AbortRetryIgnore
UseButtons = vbAbortRetryIgnore
Case YesNoCancel
UseButtons = vbYesNoCancel
Case YesNo
UseButtons = vbYesNo
Case RetryCancel
UseButtons = vbRetryCancel
End Select
‘ Raise an event to show the button type has changed.
RaiseEvent ChangeButton(Value)
End Property
Notice in this code and in the code in the earlier “Defining methods” section
that the 
RaiseEvent
method isn’t called until after the action takes place.
Always raise the event after you verify that it has occurred. Otherwise, you
might react to an event that hasn’t taken place yet (and might not take place
at all).
Using enumerated constants
The example uses a number of enumerated constants. These constants serve
to limit the number of acceptable input values. They also act as reminders of
the acceptable inputs. Listing 8-4 contains an example of a public enumeration.
Listing 8-4
Using Constants in an Object
‘ This enumeration shows the button types.
Public Enum ButtonTypes
OKOnly = 0
OKCancel = 1
194

Download 8,82 Mb.

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