Results 1 to 25 of 25

Thread: ARR! Directories....[RESOLVED]

Hybrid View

  1. #1

    Thread Starter
    Addicted Member WilliamRobinson's Avatar
    Join Date
    Feb 2005
    Posts
    219

    Re: ARR! Directories....

    Aww man that kicks ass lol what would be the code similar to that but to browse for directory

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: ARR! Directories....


  3. #3

    Thread Starter
    Addicted Member WilliamRobinson's Avatar
    Join Date
    Feb 2005
    Posts
    219

    Re: ARR! Directories....

    no, can you tell me anyway to select a directory and display the path in a textbox?

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: ARR! Directories....

    well, i do it like this
    If Dir$(App.Path & "\saveto.txt") <> "" Then
    msgbox "brtar"

  5. #5

    Thread Starter
    Addicted Member WilliamRobinson's Avatar
    Join Date
    Feb 2005
    Posts
    219

    Re: ARR! Directories....

    i dont get how that will let the user browse for a specific folder, but ill play around with that code

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: ARR! Directories....

    Add the following code to a module.
    VB Code:
    1. Private Declare Function SHBrowseForFolder _
    2.  Lib "shell32" ( _
    3.  lpbi As BROWSEINFO) As Long
    4.  
    5. Private Declare Function SHGetPathFromIDList _
    6.  Lib "shell32" ( _
    7.  ByVal pidList As Long, _
    8.  ByVal lpBuffer As String) As Long
    9.  
    10. Private Type BROWSEINFO
    11.    hWndOwner As Long
    12.    pIDLRoot As Long
    13.    pszDisplayName As String
    14.    lpszTitle As String
    15.    ulFlags As Long
    16.    lpfnCallback As Long
    17.    lParam As Long
    18.    iImage As Long
    19. End Type
    20.  
    21. Private Const BIF_RETURNONLYFSDIRS = 1
    22. Private Const BIF_DONTGOBELOWDOMAIN = 2
    23. Private Const MAX_PATH = 260
    24.  
    25. Public Function BrowseForFolder(OwnerForm As Form) As String
    26.     Dim lpIDList As Long
    27.     Dim sBuffer As String
    28.     Dim tBrowseInfo As BROWSEINFO
    29.    
    30.     With tBrowseInfo
    31.         .pszDisplayName = Space$(MAX_PATH)
    32.         .lpszTitle = "Select a folder"
    33.         .hWndOwner = OwnerForm.hWnd
    34.         .ulFlags = BIF_DONTGOBELOWDOMAIN + BIF_RETURNONLYFSDIRS
    35.     End With
    36.    
    37.     lpIDList = SHBrowseForFolder(tBrowseInfo)
    38.     If (lpIDList) Then
    39.         sBuffer = Space(MAX_PATH)
    40.         SHGetPathFromIDList lpIDList, sBuffer
    41.         BrowseForFolder = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
    42.     End If
    43. End Function
    You can then get a folder name by doing the following call from inside your form somewhere:
    VB Code:
    1. MsgBox BrowseForFolder(Me)
    Last edited by Joacim Andersson; Mar 17th, 2005 at 07:54 PM.

  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: ARR! Directories....

    no, can you tell me anyway to select a directory and display the path in a textbox?
    what i said selects the dir, and you can see if it exists. If it does then you can do some stuff with it

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