|
-
Dec 22nd, 2000, 10:10 AM
#1
Thread Starter
Lively Member
i am using commondialog to open files in directory so i have question how would i save that directory the user access last time so when user use the program again it will open the same directory which was accessed last.
-
Dec 22nd, 2000, 10:17 AM
#2
Hyperactive Member
Take a look at this...
Dim int_I As Integer
dialog1.FileName = ""
dialog1.DialogTitle = "Select the file"
dialog1.DefaultExt = "Txt"
dialog1.Filter = "All (*.*)|*.*|Text (*.txt)|*.txt"
dialog1.InitDir = GetSetting("your app", "section", "setting", "default value")
dialog1.Action = 1
int_I = InStr(1, dialog1.FileName, dialog1.FileTitle)
If int_I > 0 And Len(Trim$(dialog1.FileName)) > 0 Then
SaveSetting "your app", "section", "setting", Left$(dialog1.FileName, int_I - 1)
End If
If things were easy, users might be programmers.
-
Dec 22nd, 2000, 10:31 AM
#3
_______
<?>
'interuped before I could finish but seeing as I did it
'I may as well post it..very similar to above except I use
'a variable
Code:
Option Explicit
Public myStoredDirName As String
Private Sub Command1_Click()
On Error GoTo out:
CommonDialog1.CancelError = True
CommonDialog1.InitDir = myStoredDirName 'set dir path
CommonDialog1.CancelError = True 'used in cancel code
CommonDialog1.Filter = "All files(*.*)|*.*" 'filter for all files
CommonDialog1.ShowOpen 'show files
myStoredDirName = CommonDialog1.FileName
'open your file or whatever here
out:
'cancel was pressed
End Sub
Private Sub Form_Load()
'this will load it into the register
myStoredDirName = GetSetting("project1", "StringValue", "Value", 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'this will save it into the register when you quit
SaveSetting "project1", "StringValue", "Value", myStoredDirName
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|