Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to create an ini file

sonu_amitsonu_amit Posts: 37Member
Hi,
[red][b]Wishing You All A Very Happy And Prosperous New Year[/b] [/red]

I am supposed to create an ini file.
Can I use [purple][b]Open function[/b][/purple]
eg.
[blue][b]Open App.Path & "myFile.ini" For Output As #1[/b][/blue]
Or what could be the other way..Please suggest
Waiting for the reply
Thanks

Comments

  • GenjuroGenjuro Posts: 913Member
    : Hi,
    : [red][b]Wishing You All A Very Happy And Prosperous New Year[/b] [/red]
    :
    : I am supposed to create an ini file.
    : Can I use [purple][b]Open function[/b][/purple]
    : eg.
    : [blue][b]Open App.Path & "myFile.ini" For Output As #1[/b][/blue]
    : Or what could be the other way..Please suggest
    : Waiting for the reply
    : Thanks
    :

    Happy new year to you too.

    Well, you really aren't supposed to create an .ini in VB6.
    VB6 has no built-in support for "ini files" API, while the existence of the GetSetting and SaveSetting functions, which behave like the above mentioned APIs but store informations in the Windows Registry (which was meant to be the Win32 counterpart of Windows 3.1 ini files) hint at the idea that what you need isn't an .ini file, but a bunch of registry keys.

    Theory aside, although I always wonder why, everyone seems to use .ini files (except C++ programmers who would have an easier time doing that, but don't). So, enough of my ramblings, and let's go on with the question.

    Well, there's not really much to say. Your solution ("Open file for Input as #1") is a good one. Then you read the file line by line, and use "split" to divide keys from values.
    While you're at it, you can easily wrap it up in a nice "INIFile" class or standard module, and be done with it once and for all your VB6 projects to come. Sure, it might take a small while longer, but it's worth the extra mile.

    Or, you can declare the GetPrivateProfileString and WritePrivateProfileString; check the VB6 API viewer (a tool that comes with VB6) to find the declare, copy and paste it, and be done with it.
Sign In or Register to comment.