Importing lines from an ini file

M

Mat

Hi

I want to import certain lines of data from an ini text
file and insert it into a form text box.

eg Entry in ini file is "ArchiveDir=c:\archive". How can
I search this file and insert "c:\archive" in thetext box
txtArchive on a form?

If the user also amends the directory using the text box -
how dow you write it back to the ini file on closing ?

Any help from a realatively new VBA programmer would be
much appreciated.

Thanks, Mat.
 
J

John Nurick

Hi Mat,

Assuming it's an ordinary Windows .ini file with section headings as
well as key=value lines, e.g.
[settings]
ArchiveDir=c:\archive
you can use the Windows API functions GetPrivateProfileString() and
WritePrivateProfileString(). They're included (with detailed information
on arguments and a code example) in the API Guide (www.allapi.net), or a
web search will easily find examples of their use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top