BetaONE will rise again!


Reply
  #1  
Old 30th Dec 03, 03:56 AM
~*McoreD*~'s Avatar
~*McoreD*~ ~*McoreD*~ is offline
Super Moderator
 
Join Date: Jul 2002
Location: Australia
Posts: 2,902
~*McoreD*~ is an unknown quantity at this point
Browse for Folder and get the Folder Location

Requirements:
CommandButton -- Name: cmdBrowse
TextBox -- Name: txtRemotePath

Code:
Private Declare Function SHBrowseForFolder Lib "shell32.dll" (ByRef lpbi As Browseinfo) As Long Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath As String) As Long Private Type Browseinfo &nbsp; &nbsp;hwnd As Long &nbsp; &nbsp;pidlRoot As Long &nbsp; &nbsp;pszDisplayName As String &nbsp; &nbsp;lpszTitle As String &nbsp; &nbsp;ulFlags As Long &nbsp; &nbsp;lpfn As Long &nbsp; &nbsp;lParam As Long &nbsp; &nbsp;iImage As Integer &nbsp; &nbsp;End Type Private Sub cmdBrowse_Click() Dim fret As Long Dim buffer As String, folder As String Dim bInfo As Browseinfo '--------------------- &nbsp; &nbsp;bInfo.hwnd = Me.hwnd &nbsp; &nbsp;bInfo.pszDisplayName = Space(255) &nbsp; &nbsp;bInfo.ulFlags = &O1 &nbsp; &nbsp;bInfo.iImage = 0 &nbsp; &nbsp;bInfo.lParam = 0 &nbsp; &nbsp;bInfo.lpfn = 0 &nbsp; &nbsp;bInfo.pidlRoot = 0 &nbsp; &nbsp;bInfo.lpszTitle = "Select the folder of your choice." &nbsp; &nbsp;buffer = Space(255) &nbsp; &nbsp;fret = SHGetPathFromIDList(SHBrowseForFolder(bInfo), buffer) &nbsp; &nbsp;buffer = RTrim(buffer) &nbsp; &nbsp;folder = Left(buffer, Len(buffer) - 1) &nbsp; &nbsp;If folder <> vbNullString Then 'user selected OK &nbsp; &nbsp;If Right(folder, 1) <> "\" Then folder = folder + "\" &nbsp; &nbsp;txtRemotePath.Text = folder End If End Sub
Enjoy!
Reply With Quote
  #2  
Old 30th Dec 03, 03:56 AM
Thankbot Thankbot is offline
Senior Member
 
Join Date: Jul 2003
Location: Seph's basement, Chained to his bed
Posts: 2,191
Thankbot
2 Users already said Thank You!

TheMysterio, robinwilson16,
Reply With Quote
  #3  
Old 30th Dec 03, 03:59 AM
~*McoreD*~'s Avatar
~*McoreD*~ ~*McoreD*~ is offline
Super Moderator
 
Join Date: Jul 2002
Location: Australia
Posts: 2,902
~*McoreD*~ is an unknown quantity at this point
Browse for Folder and get the Folder Name.

Change the cmdBrowse_Click() event to this:

Code:
Private Sub cmdBrowse_Click() Dim fret As Long Dim buffer As String, folder As String Dim bInfo As Browseinfo '--------------------- &nbsp; &nbsp;bInfo.hwnd = Me.hwnd &nbsp; &nbsp;bInfo.pszDisplayName = Space(255) &nbsp; &nbsp;bInfo.ulFlags = &O1 &nbsp; &nbsp;bInfo.iImage = 0 &nbsp; &nbsp;bInfo.lParam = 0 &nbsp; &nbsp;bInfo.lpfn = 0 &nbsp; &nbsp;bInfo.pidlRoot = 0 &nbsp; &nbsp;bInfo.lpszTitle = "Select the folder of your choice." &nbsp; &nbsp;buffer = Space(255) &nbsp; &nbsp;fret = SHGetPathFromIDList(SHBrowseForFolder(bInfo), buffer) &nbsp; &nbsp;buffer = RTrim(buffer) &nbsp; &nbsp;folder = Left(buffer, Len(buffer) - 1) &nbsp; &nbsp;If folder <> vbNullString Then 'user selected OK &nbsp; &nbsp; &nbsp; &nbsp;If Right(folder, 1) <> "\" Then folder = folder + "\" &nbsp; &nbsp;Path = Mid(folder, 1, Len(folder) - 1) &nbsp; &nbsp;txtRemotePath.Text = Mid(Path, InStrRev(Path, "\") + 1) End If End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:35 PM.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.