Importing lines from an ini file

  • Thread starter Thread starter Mat
  • Start date Start date
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.
 
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.
 
Back
Top