Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I return values stored in a .ini file

Status
Not open for further replies.

shellj

Technical User
Sep 19, 2002
30
I have created a userform which consists of listboxes which hold information. Occassionally, it may be necessary to update these values so I have created an ini file to write data to. For example,

If lstAddValues.ListCount > 0 Then
lstValues.AddItem lstAddValues.List(0)
System.PrivateProfileString(FileName:="C:\My Documents\1638.ini", _
Section:=Section, Key:=lstValues.ListCount) = lstAddValues.List(0)
lstAddValues.RemoveItem (0)
End If

Because an unknown amount of data may be written to the ini file, I'm not sure how to read back all the data under a section heading without specifying the key name. In this case, I have just written all data out to the ini file as a numeric key depending on how many entries the user makes.

Can anyone help?!! I would be extremely grateful!
 
Hi Shellj,

Why use an .ini file at all, why not store the data in a hidden sheet in Excel, or a system table in Access.

Excel - read range until blank cell occurs
Access - select * from system.vars

Then because you have to update, it can be done as a script, or even write the functions to replace

Just an idea
;P
 
PaulTEG,

I have created the userform in Word and I don't really want to open up a document. Can I do this?
 
shellj,

You should be able to open an ODBC, or ADO connection to an Access database, or any other database, and read your values from there.

Bonus here is one store rather than having to revisit each machine to update .ini files.

HTH ;P
 
PAulTEG,

I'm not really sure how to go about this - I'm relatively new to VBA! Any pointers?!
 
Hi Shellj,

There's an FAQ on this in this sectioon. It's been tested in Excel, but should be okay because the same version of VBA is present in Word as well as Excel etc

HTH
;P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top