Word Document Properties


Chapter 9: Working with Arrays and Collections



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

Chapter 9: Working with Arrays and Collections
15_046500 ch09.qxp 12/5/06 5:36 PM Page 225


You have to use a little-known and somewhat undocumented method of
adding a default property to the example. When you look at the
Persons.cls
file in the source code, you see that the code actually looks
like the code in Listing 9-8:
Listing 9-8
Creating a Default Property Declaration
Public Property Get Item(Index As Variant) As Person
‘ Tell VBA this is the default property.
Attribute Item.VB_UserMemId = 0
‘ Return the requested item.
Set Item = PersonCollection.Item(Index)
End Property
However, the first line of code doesn’t appear in the IDE. VBA forces you to
use a simple but odd procedure to add this line of code. Simply use the fol-
lowing procedure to add this line of code:
1. Right-click the 
Persons
entry in the Project Explorer window, and
then choose Export File from the context menu that appears.
You see the Export File dialog box.
2. Click Save to save the file as 
Persons.cls
.
VBA exports the file.
3. Open the file in any text editor, such as Notepad.
Never use Word for this task because it can add control characters.
4. Type 
Attribute Item.VB_UserMemId = 0
as the first entry for the
Item
property.
5. Save the 
Persons.cls
file and then exit the editor.
Figure 9-3:
Create a
default
Item
property or
method 
to ensure
that your
collection
works
properly.
226
Part III: Expanding Your VBA Horizons 
15_046500 ch09.qxp 12/5/06 5:36 PM Page 226



Download 8,82 Mb.

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