Can you give me a code on how to use .ini files?
What are .ini files for?
A friend of mine told me that you can store the Path of the Executable
File in .ini files and if this .ini file is opened the path stored in it will
be used by whoever's calling it.
Can you give me a code that uses .ini files ?
I'd like to create a VB .exe file that looks in a .ini file for the Path of
the File that it has to run. For ex. I need to run "Compact.mdb" and I will place the .mdb in "C:\Access\DB\Compact.mdb".
Re: Can you give me a code on how to use .ini files?
To retrieve data
Dim FF as integer
Dim strDatabase as string
FF = freefile
Open "Yourfile.ini" for input as #FF
Input #FF,strdatabase
Close #ff
To write data
Dim FF as integer
Dim strDatabase as string
strDatabase = "C:\Access\DB\Compact.mdb"
FF = freefile
Open "Yourfile.ini" for Output as #FF
Write #FF,strdatabase
Close #ff
But if this is all the information that you are saving, I would suggest using the registry.
SaveSetting appname, section, key, setting ' to save info
ex. SaveSetting "YourAppName", "DatabaseNames", "Compacteddata","C:\Access\DB\Compact.mdb"
GetSetting(appname, section, key[, default]) 'to retrieve info
ex.
strDatabase = GetSetting("YourAppName", "DatabaseNames", "Compacteddata")
David Paulson
Re: Can you give me a code on how to use .ini files?
No, what I'd like to do is Open an .ini file that contains the Path of where my Inventory.mdb is located.
Ex. "C:\Databases\Inventory.mdb"
So what I need now is to create a Visual Basic Form that will open this .ini file and get the Path specified in the .ini file and use it to Compact the Inventory Database. If ever the user would want to change the file to be compacted and which is also located in another directory, the User can do it with changing the VB Form created. Later on, this Visual Basic Form will become an .exe file and if that happens I cannot anymore edit the code, but I can however change the File and Path of whatever I want to Compact.