Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Retrieve Folder Title from Full PathString

Posted on 2003-11-12
3
Medium Priority
?
141 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
  • 2
3 Comments
 
LVL 39

Assisted Solution

by:appari
appari earned 195 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 180 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

877 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