Applies to VB4/32 VB5+ |
The BrowseForFolder function displays the standard Browse for Folder dialog box and returns the path of the folder selected by the user:
BrowseForFolder uses the ZTrim function, which is available in General.bas. BrowseForFolder also requires the file Win32.tlb.
Folder = BrowseForFolder(hWnd, Prompt) Folder = BrowseForFolder(hWnd, Prompt, DisplayName)
hWnd specifies the window handle of the parent form, and Prompt is a message that appears above the list of folders. BrowseForFolder returns a user-friendly "display name" for the selected folder via the optional third argument.
If the user chooses the Cancel button, BrowseForFolder returns an empty string.
This code excerpt illustrates how you might call the BrowseForFolder function:
Private Sub cmdBrowse_Click() Dim Folder As String Folder = BrowseForFolder(hWnd, _ "Select the folder where your documents are stored:") If Len(Folder) > 0 Then txtFolder.Text = Folder End If End Sub
Microsoft Knowledge Base
Copyright © 2001 Rising Productions.