Word Document Properties


Chapter 8: Object-Oriented Programming



Download 8,82 Mb.
Pdf ko'rish
bet156/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   152   153   154   155   156   157   158   159   ...   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 185


It helps to look at existing classes when you think about your own class, to
see what other people have done. All the controls provided with VBA make
a good starting point because you can play with them in code to see how
Microsoft designed a particular feature. You should also examine VBA
objects, such as the ones used in the examples in this book. Control and 
component examples are readily available for your use as patterns for your
own class. (See the “Locating Just the Right Code” section of Chapter 17 for
ideas on where to find examples.) Here’s a list of the items that you should
consider copying:
Property, method, and event names:
Use recognizable (similar) names
for properties, methods, and events. For example, don’t call your 
Click
event a 
Pushed
event, because no one will know what you mean.
Mandatory features:
It’s easy to forget to include a feature in your class.
Existing classes can help you create a complete list of mandatory features,
such as a 
Caption
property, so that nothing is left out.
Design style:
Your control provides unique features and functionality.
However, it helps to look at the way other people design classes
especially their visual elements. For example, something as simple as 
providing a True/False drop-down list box for Boolean properties is very
helpful.
Visual aids:
A class can provide visual aids, such as special dialog boxes
for some types of information. Look at other classes for ideas on how
you can add visual aids to your class that make it easier to use.
Privacy:
You might find it tempting to expose every feature to anyone
who might use it. However, that approach can lead to problems because
objects are only supposed to expose necessary elements. Use other
classes as examples of what you should keep hidden in your own class.
The example in this section shows how to create a simple class. The compo-
nent encapsulates the 
MsgBox
function and makes it easier to use by helping
you see the options clearly. More importantly, the example demonstrates
how to construct properties, methods, and events for this simple class.
Defining properties

property
describes a feature of the object, such as its color, the caption, a
method of presentation (such as sunken or etched), or some other character-
istic. Don’t assume that a property has to describe a physical characteristic
of the object. A filename is a perfectly acceptable property. A property is a
special kind of object-specific data.
186

Download 8,82 Mb.

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