Click to See Complete Forum and Search --> : save new information


lloyd123
August 10th, 2001, 03:41 AM
i have a small program which consist of many texts boxes and combo boxes. every time the user goes onto the program he changes some of the information how do i save this information when he closes down the program.

Cimperiali
August 10th, 2001, 03:54 AM
You may:
store informations in a database (access,sqlserver,oracle.
This if you have a lot of informations, which does not seem your case) or
write them to a file (ascii, binary,random or ini).



Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

lloyd123
August 10th, 2001, 04:03 AM
how do i write them to a file though thanks for ya help.

Cimperiali
August 10th, 2001, 04:19 AM
have a look in help at sintax:
Open file for output as #1
and
Open file for append as #1
or at Api
writeprivateprofilestring and getprivateprofilestring
(ie of using these api:)

private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (byval lpApplicationName as string, byval lpKeyName as Any, byval lpDefault as string, byval lpReturnedString as string, byval nSize as Long, byval lpFileName as string) as Long
private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (byval lpApplicationName as string, byval lpKeyName as Any, byval lpString as Any, byval lpFileName as string) as Long
private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Ret as string, NC as Long
'Write the setting to the file (c:\test.ini) under
' Project1 -> Keyname
WritePrivateProfileString App.Title, "KeyName", "This is the value", "c:\test.ini"
'Create a buffer
Ret = string(255, 0)
'Retrieve the string
NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini")
'NC is the number of characters copied to the buffer
If NC <> 0 then Ret = Left$(Ret, NC)
'Show our string
MsgBox Ret
'Delete the file
'NOT in your case!
'Kill "c:\test.ini"
End Sub





Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

lloyd123
August 10th, 2001, 04:28 AM
the first two lines keep coming up with an error please help

Cimperiali
August 10th, 2001, 05:16 AM
Do you mean api declaration is giving you an error?
Put those api in general section of a form.

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Cimperiali
August 10th, 2001, 05:19 AM
The example presume
"c:\test.ini"
exists on your hard disk
if not, create a file in C:\ named "test" and set its extension "ini".

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater