Results 1 to 4 of 4

Thread: dir help ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Cool 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

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    So in the Change event reset it back to the inital directory.

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    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.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    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
  •  



Click Here to Expand Forum to Full Width