Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet185/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   181   182   183   184   185   186   187   188   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part III: Expanding Your VBA Horizons 
15_046500 ch09.qxp 12/5/06 5:36 PM Page 222


‘ Create an instance of this type.
Private ThePerson As APerson
Public Property Get Name() As String
‘ Get the current user name.
Name = ThePerson.Name
End Property
Public Property Let Name(Value As String)
‘ Set the new user name.
ThePerson.Name = Value
End Property
The object for this example essentially maintains a reference to the user-
defined data type and exposes the individual elements as properties. The list-
ing shows the user-defined type declaration. Notice that the declaration
doesn’t vary from that used for native data types.
The code consists of three pairs of property declarations — one for each
variable in the 
APerson
data type. Each property provides both read and
write capabilities. Although this is an object, the individual variables aren’t
objects, so you use the 
Let
and 
Get
methods of exposing them.
Defining a collection of contacts
After you have a single object to use, it’s time to create a collection of them.
A collection doesn’t have to implement the methods and properties found in
the 
Collection
class, but it helps if it does. It pays to look at the collections
in VBA for ideas on which methods and properties you can implement.
Always implement the 
Item
property because you need it for most of your
code. Listing 9-7 shows an example of a typical collection.
Listing 9-7
Manipulating Data in Collections
‘ Declare the collection.
Private PersonCollection As Collection
Public Sub Add(Item As Person, _
Optional Key As String, _
Optional Before As Integer, _
Optional After As Integer)
‘ Determine whether there is a Key.
If Not Key = “” Then
‘ Determine whether there is a Before value.
If Before > 0 Then
(continued)
223

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   181   182   183   184   185   186   187   188   ...   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