Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet192/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   188   189   190   191   192   193   194   195   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part III: Expanding Your VBA Horizons 
16_046500 ch10.qxp 12/5/06 5:36 PM Page 232


Listing 10-1
Using a Dictionary Object
Public Sub WriteDictionary()
‘ Create a variable to hold the data.
Dim DataString As Variant
‘ Create the dictionary for user settings.
Dim UserSetting As Dictionary
Set UserSetting = New Dictionary
UserSetting.Add “Greeting”, “Hello”
UserSetting.Add “Language”, “English”
‘ Create the dictionary for application configuration.
Dim AppConfig As Dictionary
Set AppConfig = New Dictionary
AppConfig.Add “ShowHelpMenu”, “True”
AppConfig.Add “AllowChanges”, “True”
‘ Create the configuration file.
Dim TheConfig As TextStream
OpenWriteConfig “DictionaryDemo”, “Data.INI”,
TheConfig
‘ Write the UserSetting Dictionary.
TheConfig.WriteLine “[UserSetting]”
For Each DataString In UserSetting
TheConfig.Write DataString
TheConfig.Write “=”
TheConfig.WriteLine UserSetting.Item(DataString)
Next
‘Write the AppConfig Dictionary.
TheConfig.WriteLine “[AppConfig]”
For Each DataString In AppConfig
TheConfig.Write DataString
TheConfig.Write “=”
TheConfig.WriteLine AppConfig.Item(DataString)
Next
‘ Close the configuration file.
TheConfig.Close
End Sub
The code begins by creating two 
Dictionary
objects — one for each section
of the INI file. It fills these objects with data for the example. In your program,
you fill the 
Dictionary
objects with your program settings or other data.
The code calls the 
OpenWriteConfig
sub-procedure next. This special func-
tion that I wrote looks almost exactly the same as the beginning code in the
earlier “Writing to the file” section. When this call returns, 
TheConfig
points
to a 
TextStream
that the code can use for writing.
233

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   188   189   190   191   192   193   194   195   ...   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