Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet153/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   149   150   151   152   153   154   155   156   ...   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 182


Understanding properties, 
methods, and events
All classes include some comment elements. Because a class is essentially
a black box that accepts input and provides output, you need some way
to interact with it. Classes provide three common constructions that help
you interact with them: properties, methods, and events. The following list
describes each of these constructions.
Properties:
A property provides a means to access data within the
object. Unlike a variable, a property can include code that controls
the interaction with the object data. The property might check the data
type of the incoming request or format the outgoing data in some way.
Properties can provide read/write access so that you can change the
object data as well as use it in your own code. However, a class devel-
oper can also choose to make a property read-only or write-only.
Methods:
A method provides a means of asking the object to perform
a task. As with a 
Function
or 
Sub
, a method can return a value and
accept data as input. Unlike with a 
Function
or 
Sub
, you need not
worry about the inner workings of the method. Your only concern is
that you must provide certain input to obtain specific output. In some
cases, you will find methods that accept no input and provide no output
but still perform a task. For example, a 
Refresh()
method may tell the
object to refresh its data. Methods always perform a task, but need not
work with data (from an external perspective) to do it.
Events:
An event is the object’s way of interacting with the outside world.
An event signals that something has happened. A user might have clicked
a button, or the status of a text box might have changed. The events that
an object signals depend on the communication that the class designer
chooses to provide. Even when an object signals an event, however, noth-
ing takes place in your code unless you create an event handler, a special
Sub
or 
Function
, to do something with the event.
Defining classes
You might want to think of a class as a substitute for a 
Function
or a 
Sub
, but
classes are separate. A 
Function
or 
Sub
always describes a 
procedure
— a
list of steps. A 
class
describes a thing. You can visualize a file because it’s a
thing. That’s why VBA uses classes to describe the file system and uses objects
to work with individual file system elements, such as a drive. Although you
might read that objects are substitutes for procedures, the two kinds of pro-
gramming have definite places in your programmer’s toolbox. Make sure that
you work with both as needed.
183

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   149   150   151   152   153   154   155   156   ...   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