Solved

Retrieve Folder Title from Full PathString

Posted on 2003-11-12
3
138 Views
Last Modified: 2010-05-01
Good day
i have a drivelistbox,a dirlistbox and a filelistbox.
connected in tree order(if you choose a directory in dirlistbox, all files in that directory will be displayd in filelistbox)

in the end i have a string say FULLPATH

fullpath is for e.g.
C:\MyProgram\MyFolder

what i need is to get only the folder name and not the full path as shown above
so i guess i need some help on a module
which i can send the full path to.

I guess a good idea will be to start from the back till i get a "\"
but im lost on this
0
Comment
Question by:jxharding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Assisted Solution

by:appari
appari earned 65 total points
ID: 9731527
try this

strFullPath="C:\MyProgram\MyFolder"
left( strFullPath,instrrev(strFullPath,"\"))
0
 
LVL 39

Expert Comment

by:appari
ID: 9731529
try this

strFullPath="C:\MyProgram\MyFolder"
msgbox left( strFullPath,instrrev(strFullPath,"\"))
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 60 total points
ID: 9731773
You can split the entire path into an array and access each folder via a seperate index. The below example uses UBound(sArray) to MsgBox the last index in the array.

Private Sub Form_Load()
    Dim sPath As String, sArray() As String
    sPath = "C:\MyProgram\MyFolder"
    sArray = Split(sPath, "\")
    MsgBox sArray(UBound(sArray))
End Sub


0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question