Word Document Properties


Figure 8-1: Modifying the Instancing property for class usage. 197 Chapter 8: Object-Oriented Programming



Download 8,82 Mb.
Pdf ko'rish
bet167/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   163   164   165   166   167   168   169   170   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Figure 8-1:
Modifying
the
Instancing
property for
class usage.
197
Chapter 8: Object-Oriented Programming
14_046500 ch08.qxp 12/5/06 5:36 PM Page 197


The result is a message box that doesn’t display any icon. The class version
eliminates this problem. You can choose only one icon, and you don’t have to
remember the icon choices.
The class form of the 
MsgBox
function also makes setups easier. You can use
this class to set up certain types of message boxes that you use regularly at
the beginning of the program. For example, you can use it to set up an error
message box. When an error occurs, you can quickly set the 
Caption
property
and use the 
Show
method to display the message box. The idea is that the error
message box is consistent and easy to use.
The example class in this chapter shows the three reasons to encapsulate
functions and also the three things that you should consider when you’re 
creating new objects. The following list summarizes these three elements:
Ease of use:
A class should always make coding easier. Useful classes
reduce the programming burden rather than increase it.
Reduced learning curve:
A class should reduce the need to memorize
things or to figure out odd programming techniques. A class should pro-
vide easy-to-understand methods, properties, and events.
Enhanced reliability:
A well-designed class provides error handling not
found in a function. The class should sensibly restrict actions that result
in coding errors. It should also check inputs to ensure that the information
is correct.
Using Your New Object in an Application
The 
SpecialMsg
class is ready for use in an application. You can use it in
place of the 
MsgBox
function . . . and in some places where the 
MsgBox
func-
tion simply won’t work. For example, you can’t ask the 
MsgBox
function to
generate events, but the 
SpecialMsg
class does. The code in Listing 8-6
shows an example of the 
SpecialMsg
class in action.

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   163   164   165   166   167   168   169   170   ...   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