I have this program which has a kind of dialog with user-setup options. I need to be able to store this information somewhere so that next time it is executed the information is reloaded. I know this can be done but I can only do it with a text file...
Does anyone know how I can do this?
netSurfer
Jan 17th, 2000, 10:13 PM
dim intFreeFile as integer, strFileName as string
intFreeFile = FreeFile
strFileName = "userPrefs.txt"
Open strFileName For Output As #intFreeFile
'now you can write the prefs to the file
'if you have more than 1 and want them on
'seperate lines, use a different Print
'statement. If you want the prefs on 1 line,
'add them all into a string and print that.
Print #intFreeFile, "User Prefs"
Close #intFreeFile
Hope that helps. Yo can also write it to an INI file but this works to write plain text to any file name you want. To open it:
intFreeFile = FreeFile
strFileName = "userPrefs.txt"
Open strFileName For Input As #intFreeFile
dim strLine as string
Do Until EOF(intFreeFile)
Line Input #intFreeFile, strLine 'will dump the line into strLine
If Mid(strLine, 1, 6) = "pref1" Then
strPref1 = Mid(strLine, 9, (Len(strLine) - 9))
ElseIf Mid(strLine, 1, 4) = "pref2" Then
strPref2 = Mid(strLine, 7, (Len(strLine) - 7))
End If
'now have read 1 line and have searched for 2 preferences. Now need to loop to continue to go through the file
Loop
Can also write the file info into an array like this:
Line Input #intFreeFile, strArray(intI)
increase the intI each time you go through the loop.
This is only 1 way to do it, hope this helps.
Mark Sreeves
Jan 17th, 2000, 10:18 PM
A simple way is to use SaveSetting and GetSetting to store data in the registry
take a look at the VB help files for examples
------------------
Mark Sreeves
Analyst Programmer
Mark.Sreeves@Softlab.co.uk
A BMW Group Company