Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet194/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   190   191   192   193   194   195   196   197   ...   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 234


Finally, the code creates a text file to hold the data that the application saves.
Because an INI file is essentially a text file, you work with it as a text file by
using 
FS.CreateTextFile()
. When the call is completed, 
Output
contains
a pointer to the new file.
You might wonder why the application separates the code in the
OpenWriteConfig
sub-procedure from the rest of the code. Generally, you
do this to make the code a little more generic. You can use 
OpenWriteConfig
to open any file necessary for this application. In fact, the sub-procedure is
so generic that you can use it as is with any application.
Reading an INI file
Reading the INI file is a little more difficult than writing to it. The problem is
that you have straight text and don’t know whether someone has changed
the file in some way. Parsing straight text means reading key values and
acting on them. (
Parsing
is the act of reading each word individually and
determining what that word means in the context of the task at hand.) Listing
10-3 contains the code that you need in order to read an INI file.
Listing 10-3
Reading an INI File with a Dictionary
Public Sub ReadDictionary()
‘ Create an individual data element.
Dim DataElement As String
‘ Create a dictionary selector.
Dim Selector As Dictionary
‘ Create a string indexer.
Dim Index As Long
‘ Create the dictionary for user settings.
Dim UserSetting As Dictionary
Set UserSetting = New Dictionary
‘ Create the dictionary for application configuration.
Dim AppConfig As Dictionary
Set AppConfig = New Dictionary
‘ Try to open the configuration file.
Dim TheConfig As TextStream
If Not OpenReadConfig(“DictionaryDemo”, “Data.INI”,
TheConfig) Then
(continued)
235

Download 8,82 Mb.

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