Solved

Retrieve Folder Title from Full PathString

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…

777 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