Solved

Retrieve Folder Title from Full PathString

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now