Word Document Properties


Chapter 10: Working with Disk Files



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

Chapter 10: Working with Disk Files
16_046500 ch10.qxp 12/5/06 5:36 PM Page 235


Listing 10-3
(continued)
‘ Exit the sub if not successful.
Exit Sub
End If
‘ Read the file into the dictionaries.
While Not TheConfig.AtEndOfStream
‘ Read the data element.
DataElement = TheConfig.ReadLine
Select Case DataElement
‘ Set the selector for AppConfig.
Case “[AppConfig]”
Set Selector = AppConfig
‘ Set the selector for UserSetting.
Case “[UserSetting]”
Set Selector = UserSetting
‘ Fill the selected dictionary with data.
Case Else
Index = InStr(1, DataElement, “=”)
Selector.Add Left(DataElement, Index - 1),
_
Mid(DataElement, Index + 1)
End Select
Wend
‘ Close the configuration file.
TheConfig.Close
End Sub
The code begins by creating the two 
Dictionary
objects that you need in
order to hold the information. It also creates a special 
Dictionary
object
named 
Selector
and a few variables that it needs in order to parse the file
content.
The program begins by opening the configuration file and creating the
TextStream
by using the 
OpenReadConfig
function. This function is very
similar to the beginning code for the example in the earlier “Reading from the
file” section. When the function returns, it’s 
True
if it opened the file. If the
return value is 
False
, the 
ReadDictionary
sub-procedure exits because
there’s no file information to parse.
Notice how this example uses the 
AtEndOfStream
property. This use is
more common than the use shown in the earlier “Reading from the file” sec-
tion. The 
While...Wend
loop continues reading data until there’s no more
236

Download 8,82 Mb.

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