Results 1 to 3 of 3

Thread: sequential files

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    7

    Unhappy

    I need a little help with coding out a project. I have it running fine all kinds of whistles and bells except for one thing. I can not get my menu save and open buttons to work. I need to save data from a list box to a file then load it back when i restart the project. Any ideas out there?
    Thanks,
    Kelly

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You could use a flat file to store the list items in, i.e.
    Code:
    Private Sub Form_Load()
        Dim iFile As Integer
        Dim sItem As String
        If Len(Dir(App.Path & "\List.dat")) Then
            iFile = FreeFile
            Open App.Path & "\List.dat" For Input As iFile
            While Not EOF(iFile)
                Input #iFile, sItem
                List1.AddItem sItem
            Wend
            Close iFile
        End If
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        Dim iFile As Integer
        Dim lCount As Long
        
        iFile = FreeFile
        Open App.Path & "\List.dat" For Output As iFile
        For lCount = 0 To List1.ListCount - 1
            Print #iFile, List1.List(lCount)
        Next
        Close iFile
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    7

    Exclamation

    The save file works fine, but not the open part. I am using mnuOpen click event to open the file. I can see the saved file but can't quite seem to open it. Thanks for the help and if you have any more ideas as to how to open the file in a click event it would be helpful. I suck at files but can do some pretty decent forms (for a begginer)
    Kelly

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