msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Save settings to file

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
Kashif Qureshi



Joined: 04 Oct 2007
Posts: 2

PostPosted: Fri Dec 01, 2006 2:02 am    Post subject: Save settings to file Reply with quote

Hi,

I need helt regarding settings I want to save to an INI-file.
I got a function wich allows me to read settings from the INI-file when the
application starts up. But I want to save a few settings into the INI-file
at some time, like when the appl is exited.

See below the function for reading the seetings. But how do I write to same
spot in the INI-file the settings I need to save?
Do I need another function for save seetings? And how will I be sure that I
really update correct fields in my INI-file?

Can someone please help.

Thanx.


'FUNCTION FOR READING FROM THE INI-FILE
Private Function GetIniSetting(ByVal header As String, ByVal Item As String)
As String
Dim Rets As String
Dim i As Integer

Rets = Space$(200)
i = GetPrivateProfileString(header, Item, " ", Rets, Len(Rets), PROF_FILE)
Rets = Trim$(Rets)
If (Len(Rets) > 1) Then
GetIniSetting = Left$(Rets, Len(Rets) - 1)
Else
GetIniSetting = ""
End If

End Function

'AND SOME OF THE SEETING ARE UPLOADED AT START-UP
Private Sub Form_Load()

lstSentLog.Clear

'LÄSER IN INSTÄLLNINGAR FRÅN INI-FIL
LogPath = GetIniSetting("PATHS", "LOGGPATH")
Label1.Caption = "Logpath: " & LogPath
gbRunLog = (GetIniSetting("LOG", "LOGGNING") = "Ja")
Label2.Caption = "Loggning aktiv: " & gbRunLog

intAntCC2 = GetIniSetting("AntalTel", "CC2")
intAntBT1 = GetIniSetting("AntalTel", "BT1")
' intAntPL = GetIniSetting("AntalTel", "PL")

Call LaddaText
Call LaddaTel
LogToPrioWindow (Now & " Form load utförd")

Node = "FIX"
Field = "F_CV"
End Sub

--


//Kashif

*******
The brain is a wonderful organ; it starts working the moment you get up in
the morning and does not stop until you get to the office
*******

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Max Kudrenko



Joined: 04 Oct 2007
Posts: 47

PostPosted: Fri Dec 01, 2006 11:09 am    Post subject: Re: Save settings to file Reply with quote

Kashif,

Examine WritePrivateProfileString function:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/writeprivateprofilestring.asp.

Hope this helps,

Max Kudrenko
Brainbench MVP Program for Visual Basic
www.brainbench.com


Kashif Qureshi wrote:
> Hi,
> I need helt regarding settings I want to save to an INI-file.
> I got a function wich allows me to read settings from the INI-file when the
> application starts up. But I want to save a few settings into the INI-file
> at some time, like when the appl is exited.
> See below the function for reading the seetings. But how do I write to same
> spot in the INI-file the settings I need to save?
> Do I need another function for save seetings? And how will I be sure that I
> really update correct fields in my INI-file?
> Can someone please help.
> Thanx.
>
> 'FUNCTION FOR READING FROM THE INI-FILE
> Private Function GetIniSetting(ByVal header As String, ByVal Item As String)
> As String
> Dim Rets As String
> Dim i As Integer
> Rets = Space$(200)
> i = GetPrivateProfileString(header, Item, " ", Rets, Len(Rets), PROF_FILE)
> Rets = Trim$(Rets)
> If (Len(Rets) > 1) Then
> GetIniSetting = Left$(Rets, Len(Rets) - 1)
> Else
> GetIniSetting = ""
> End If
> End Function
> 'AND SOME OF THE SEETING ARE UPLOADED AT START-UP
> Private Sub Form_Load()
> lstSentLog.Clear
> 'LÄSER IN INSTÄLLNINGAR FRÅN INI-FIL
> LogPath = GetIniSetting("PATHS", "LOGGPATH")
> Label1.Caption = "Logpath: " & LogPath
> gbRunLog = (GetIniSetting("LOG", "LOGGNING") = "Ja")
> Label2.Caption = "Loggning aktiv: " & gbRunLog
> intAntCC2 = GetIniSetting("AntalTel", "CC2")
> intAntBT1 = GetIniSetting("AntalTel", "BT1")
> ' intAntPL = GetIniSetting("AntalTel", "PL")
> Call LaddaText
> Call LaddaTel
> LogToPrioWindow (Now & " Form load utförd")
> Node = "FIX"
> Field = "F_CV"
> End Sub
Back to top
View user's profile Send private message
Ken Halter



Joined: 04 Oct 2007
Posts: 4150

PostPosted: Fri Dec 01, 2006 12:28 pm    Post subject: Re: Save settings to file Reply with quote

"Kashif Qureshi" wrote in message $E02.10148@newsb.telia.net...
> Hi,
>
> I need helt regarding settings I want to save to an INI-file.
> I got a function wich allows me to read settings from the INI-file when
> the application starts up. But I want to save a few settings into the
> INI-file at some time, like when the appl is exited.
>
> See below the function for reading the seetings. But how do I write to
> same spot in the INI-file the settings I need to save?
> Do I need another function for save seetings? And how will I be sure that
> I really update correct fields in my INI-file?
>
> Can someone please help.
>
> Thanx.

Here's an extremely easy way to work with ini files.

Easy INI File Access
http://www.vbaccelerator.com/home/vb/Code/Libraries/Registry_and_Ini_Files/Easy_Ini_File_Access/article.asp

....and, another..

kpIni
http://vb.mvps.org/samples/project.asp?id=kpIni


> *******
> The brain is a wonderful organ; it starts working the moment you get up in
> the morning and does not stop until you get to the office
> *******

How true

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
How to save with only WebBrowser: Save html+picture without How to save with only WebBrowser: Save html+picture without dialog box? What I Have is: 300, 300 I don't want this code. I want same code like this: html+pic) What

PLZ help newbie w/ save command I created my 1st application and deployed it. I'm able to access & open it straight from my desktop with no problem. All the information and calculations designed work flawlessly. The only problem is that when I save the form and name it to a folder for f

Save Images to Microsoft Access Dear Friends How can I save and retrieve images using vb6 and Microsoft Access Thx Anuradha

how to show the "txt code" that the WebBrowser wont to save how to show the "txt code" that the WebBrowser wont to save when he wont to save html+pictures with the "dialogbox" - before saving. this is the code to open the save "dialogbox" 0, 0 this i

Howto make a Copy of File and retrieve the resulting file na Hi! I want to make copy of a file with the target destination the same as the original file and let Windows pick the filename, e.g. Copy of File.txt of Copy(2) of File.txt. This works fine, but my problem is that I am not able to get hold of the resultin
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group