Results 1 to 13 of 13

Thread: Saving lists...

  1. #1

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472

    Talking

    I have a program that allows a user to navigate through folders to get to the files they are looking for...this program displays/plays the files, how can I save the directory they leave in? like once they quit the program, the current directory is the one that will be open next time they load the program...


  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim stCurDir As String
        Dim stIniFile As String
        
        stIniFile = App.Path & "\myIni.Ini"
        
        'make sure the file exists
        If Dir$(stIniFile) <> "" Then
          Open stIniFile For Input As #1
          
          Line Input #1, stCurDir
        
          ChDir (stCurDir)
        
          Close #1
        End If
        
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Dim stIniFile As String
        
        stIniFile = App.Path & "\myIni.Ini"
        
        Open stIniFile For Output As #1
        
        Print #1, CurDir
        
        Close #1
        
        
    End Sub
    Iain, thats with an i by the way!

  3. #3

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    input past end of file......error...

  4. #4

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472

    nevermind...hah

    nevermind...hah

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Works on mine.
    Iain, thats with an i by the way!

  6. #6

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    Do I post it in a module, cause its not writing to the ini file...

  7. #7

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472

    Talking

    there, got it...it was being a *****

  8. #8
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Works fine on mine.

    This new and improved code should cut out most errors.



    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim stCurDir As String
        Dim stIniFile As String
        
        stIniFile = App.Path & "\myIni.Ini"
        
        'make sure the file exists
        If Dir$(stIniFile) <> "" Then
          Open stIniFile For Input As #1
          
          Line Input #1, stCurDir
          
          If Trim$(stCurDir) <> "" Then
            If Dir$(stCurDir, vbDirectory) <> "" Then
              ChDir (stCurDir)
            End If
          End If
        
          Close #1
        End If
        
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Dim stIniFile As String
        
        stIniFile = App.Path & "\myIni.Ini"
        
        Open stIniFile For Output As #1
        
        Print #1, CurDir
        
        Close #1
        
        
    End Sub
    I think you can probaly use some API like get setting etc, but i don't know how.
    Iain, thats with an i by the way!

  9. #9

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    it made the list, but made the wrong directory...

  10. #10

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    does the form unload getting read? do i need to have it any place special...?

  11. #11

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    It keeps writing the directory the program is currently in...

  12. #12

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472

    Talking

    fixed it, thanks

  13. #13
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341

    Smile

    I have a file that will access .ini files and code into them, you could just save it in a single file, or you could save it in the registry. then just put code in to open the file/reg.

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