Consulting

Results 1 to 5 of 5

Thread: Solved: other possibilities?

  1. #1
    VBAX Regular
    Joined
    Jan 2009
    Posts
    93
    Location

    Solved: other possibilities?

    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 , Pavel

    [VBA]
    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
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    MsgBox a(UBound(a) - 1)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jan 2009
    Posts
    93
    Location

    Wink

    It is Unebelievable, Thank You XLD for all your support,

    me firstly did not know how to use it

    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

  4. #4
    VBAX Regular
    Joined
    Jan 2009
    Posts
    93
    Location

    Smile

    This was solved by xld, not by me, Thanks again a lot XLD, Pavel

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    In practice it would be best to test the last character for \, as a precaution

    [vba]

    MsgBox IIf(Right$(place, 1) = "\", a(UBound(a) - 1), a(UBound(a)))
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •