|
-
Oct 28th, 2001, 09:31 PM
#1
Thread Starter
Lively Member
dir help ?
Hi all
can anyone help with this.
I have a form with a drive list box on it
And i have a directory list box also.
What i'm looking for is when my form load the directory list box shows the path on the dir that i want the user to use.
I do not want them to be able to change the path.
Thanks for the help
-
Oct 28th, 2001, 09:33 PM
#2
So Unbanned
So in the Change event reset it back to the inital directory.
-
Oct 29th, 2001, 03:26 AM
#3
You can set this via the Path function of the control :
Code:
Private Sub Form_Load()
Dir1.Path = "C:\My_Folder"
End Sub
However, I'm gonna get technical for once as there's so many things that can go wrong with this. 
Code:
Private Declare Function GetWindowsDirectory Lib _
"kernel32" Alias "GetWindowsDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
Dim strWinDir As String, lngBuffer As Long
strWinDir = Space(255)
lngBuffer = GetWindowsDirectory(strWinDir, 255)
strWinDir = Left(strWinDir, lngBuffer)
If Len(Dir$(Left(strWinDir, 3) & "My_Folder")) <> 0 Then
Dir1.Path = Left(strWinDir, 3) & "My_Folder"
Else
MkDir Left(strWinDir, 3) & "My_Folder"
Dir1.Path = Left(strWinDir, 3) & "My_Folder"
End If
End Sub
Sorry this is a bit long, but it'll look for the windows directory, and return the drive this is on, so if my boot drive was D: rather than C: this would be picked up.
Also, if the My_Folder folder didn't exist, the above wouldn't crash like the top example, it will create thge folder, then set the directory boxes path to this. 
Finally, so they won't be able to change the location, use the following after this code :
Code:
Dir1.enabled = false
Last edited by alex_read; Oct 29th, 2001 at 03:57 AM.
-
Oct 29th, 2001, 08:48 AM
#4
Leave your dir box enabled, but in its change event put the directory in that you want them to be, i.e.[/Highlight]Dir1.Path = "c:\yourdir"[/Highlight]That way, they can click on this all day along and it is only going to take them right back to were you want them to be.
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
|