|
-
Jun 5th, 2000, 11:06 PM
#1
Thread Starter
Hyperactive Member
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...
-
Jun 5th, 2000, 11:18 PM
#2
Fanatic Member
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!
-
Jun 5th, 2000, 11:24 PM
#3
Thread Starter
Hyperactive Member
input past end of file......error...
-
Jun 5th, 2000, 11:25 PM
#4
Thread Starter
Hyperactive Member
-
Jun 5th, 2000, 11:27 PM
#5
Fanatic Member
Iain, thats with an i by the way!
-
Jun 5th, 2000, 11:30 PM
#6
Thread Starter
Hyperactive Member
Do I post it in a module, cause its not writing to the ini file...
-
Jun 5th, 2000, 11:31 PM
#7
Thread Starter
Hyperactive Member
there, got it...it was being a *****
-
Jun 5th, 2000, 11:33 PM
#8
Fanatic Member
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!
-
Jun 5th, 2000, 11:33 PM
#9
Thread Starter
Hyperactive Member
it made the list, but made the wrong directory...
-
Jun 5th, 2000, 11:38 PM
#10
Thread Starter
Hyperactive Member
does the form unload getting read? do i need to have it any place special...?
-
Jun 5th, 2000, 11:40 PM
#11
Thread Starter
Hyperactive Member
It keeps writing the directory the program is currently in...
-
Jun 5th, 2000, 11:45 PM
#12
Thread Starter
Hyperactive Member
-
Jun 6th, 2000, 12:32 AM
#13
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|