Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an INI file.

Status
Not open for further replies.

rpk2006

Technical User
Apr 24, 2002
225
IN
Hi,

I want to make INI file for my App., in which I want to
store settings like Form height and width, Top position
etc.. I want that if the user has dragged a form to any
location, the location of the form is recorded in an INI
file, so that when the user starts the application next
time, the forms are opened at the location where the user
last moved them.

How to write and read from any file? Suppose, I want to
make an INI file with the heading "Display settings"
under which the Form position settings are written as:
Form.Height = 3400
etc.

Please help me. There is always a new solution for the same problem.

Anonymous
 
Have you considered using the registry? VB provides the GetSetting and SaveSetting functions for easy access to the registry. I use them often to store personalized settings and last state settings. You could easily store top and left values as well as height and width.

Help files can give you more information. Thanks and Good Luck!

zemp
 
1. Do a search on this (TEk-Tips) site. There are several posts that answer this question (faq222-39 amongst many others)
2. Look up VBHelp.

3. See FAQ referred below! Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Thanks, please clarify how to use "GetSetting" and "SaveSetting" in VB 6. Illustrative Example will be appreciated. There is always a new solution for the same problem.

Anonymous
 
the following example saves the position and size of the form to the registry using 'Savesetting' function

' save the forms last position
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, Me.Name, &quot;Left&quot;, Me.Left
SaveSetting App.Title, Me.Name, &quot;Top&quot;, Me.Top
SaveSetting App.Title, Me.Name, &quot;Width&quot;, Me.Width
SaveSetting App.Title, Me.Name, &quot;Height&quot;, Me.Height
End If

the following example retrives the position and size(saved) from the registry using the 'Getsetting' function

' get the forms last position
Me.Left = GetSetting(App.Title, Me.Name, &quot;Left&quot;, Me.Left)
Me.Top = GetSetting(App.Title, Me.Name, &quot;Top&quot;, Me.Top)
Me.Width = GetSetting(App.Title, Me.Name, &quot;Width&quot;, 10185)
Me.Height = GetSetting(App.Title, Me.Name, &quot;Height&quot;, 8490)

hope this helps
gaorr
 
Thanks a lot Gaorr. There is always a new solution for the same problem.

Anonymous
 
Private Sub mnuLoad_Click()
fnum = FreeFile
Open &quot;C:\My Documents\Hydroponics\Controler2\Controler2.ini&quot; For Input As fnum

Input #fnum, var1, var2,etc...
Close fnum
End Sub

Private Sub mnuSave_Click()
fnum = FreeFile
Open &quot;C:\My Documents\Hydroponics\Controler2\Controler2.ini&quot; For Output As fnum

Write #fnum, var1, var2,etc...
Close fnum
End Sub

You would need code to get var1 value from object.property before doing the save, and setting the .properties after the load.
You would just have your mnuExit sub call the save sub, and have the load called in the load_form()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top