Solved

Retrieve Folder Title from Full PathString

Posted on 2003-11-12
3
139 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

615 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