Results 1 to 3 of 3

Thread: Where can I store program data after it ends??

  1. #1


    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?

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Calgary Alberta


    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


    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.

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999


    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
    A BMW Group Company

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width