-
1 Attachment(s)
Read text files?Pls Help
How to read a text file in VB. I'm going to access many text files in my VBA program but want to do it neatly. For eg.in my codes, if I have a string named "_APP_PATH" my program shoud access a txt file called "config.txt" and read line by line for the word "_APP_PATH". If it finds it, that means the line below that word is the directory path eg. "C:\windows\desktop\create"...so this string(the path) should be assigned to "_APP_PATH" in my codes...How to doit? Any better way.Attached is how the text file should look like.PLs..I need a solution for it.Pls helpThanks alot.
-
Didn't I allready reply to that??
You can do something loike that (storing data) in an INI-file . Use the API-Calls getprivateprofilestring and writeprivateprofilestrig to do that (neatly)
Since you are using VBA, why don't you store the data in "parent" file (i.e. the file which holds the VBA-source code).
-
As opus has already said, using an ini file is what you want. Your description of the text file matches what ini files are intended for.
Another option is to store it in the registry.
Either option removes the need for you to parse a text file as the API calls will take care of everything for you.
Dave