PDA

View Full Version : Solved: other possibilities?



hardlife
03-31-2010, 10:10 AM
Please, are there another ways to do this?

me is just now trying to extract last directory,
does anybody know other possibilities to do this?

thanks everybody for any opinion,
HAPPY AND SUNNY DAY to everyone :hi:, Pavel


Sub last_directory_in_path()

Dim a() As String, place As String

place = "c:\Program Files\Common Files\Microsoft Shared\Stationery\"

a() = Split(place, "\")

MsgBox a(Len(place) - Len(Replace(place, "\", "")) - 1)

End Sub

Bob Phillips
03-31-2010, 11:09 AM
MsgBox a(UBound(a) - 1)

hardlife
03-31-2010, 04:23 PM
It is Unebelievable, Thank You XLD for all your support,

me firstly did not know how to use it :hi:

but it works like a charm.

You are the best teacher xld,

me is wishing You all the best,

Good Luck and Happy Day,

Pavel Humenuk

hardlife
03-31-2010, 04:27 PM
This was solved by xld, not by me, Thanks again a lot XLD, Pavel :hi:

Bob Phillips
04-01-2010, 12:59 AM
In practice it would be best to test the last character for \, as a precaution



MsgBox IIf(Right$(place, 1) = "\", a(UBound(a) - 1), a(UBound(a)))