mustntgrumble
asked on
Reading a .cfg file
Hi,
I would like to read a variable from a file Config.cfg which has a title in square brackets [MyValue] and then underneath it says MyValue = VALUE. How do I get VALUE using VB please?
Many thanks.
I would like to read a variable from a file Config.cfg which has a title in square brackets [MyValue] and then underneath it says MyValue = VALUE. How do I get VALUE using VB please?
Many thanks.
try using the GetPrivateProfileString API Call.
try using the GetPrivateProfileString API Call.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just to clarify...
Your config.cfg file seems to be formatted as a 'standard' INI file - so you can use the INI file API functions as described above.
When you call the functions, just tell it that your 'iniFile' is really a 'cfg file' !!!!
The Section and Item values relate to the ...
- -- -- -- -- -- -- -- -- -
[Section]
Item=aValue
myItem=myValue
[Another Section]
anotherItem=aValue
- -- -- -- -- -- -- -- -- -
Your config.cfg file seems to be formatted as a 'standard' INI file - so you can use the INI file API functions as described above.
When you call the functions, just tell it that your 'iniFile' is really a 'cfg file' !!!!
The Section and Item values relate to the ...
- -- -- -- -- -- -- -- -- -
[Section]
Item=aValue
myItem=myValue
[Another Section]
anotherItem=aValue
- -- -- -- -- -- -- -- -- -
Just a warning--the GetPrivateProfileString routine won't seem to function on files greater than 64K.
Hi mustntgrumble,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:
Accept rspahitz's comment(s) as an answer.
mustntgrumble, if you think your question was not answered at all or if you need help, you can simply post a new comment here. Community Support moderators will follow up.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:
Accept rspahitz's comment(s) as an answer.
mustntgrumble, if you think your question was not answered at all or if you need help, you can simply post a new comment here. Community Support moderators will follow up.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
I think you meant WolfgangKoenig. Mine was a comment and not an answer.
Thanks for catching my error rspahitz. Suggested disposition:
Accept WolfgangKoenig's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer
Accept WolfgangKoenig's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer
Comment from expert accepted as answer
Computer101
E-E Moderator
Computer101
E-E Moderator