Results 1 to 8 of 8

Thread: Quickie!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121

    Quickie!

    I am feeling like an idiot today but...

    I have a string which holds the path:
    C:\WINNT\Media\Windows Logon Sound.wav
    I just wanna be able to chop off the file name and put it in a listbox. I am just being stupid today and can't think of the best way to do it, just a function to chop off anything after the last " \" and return it as its own string.


    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  2. #2
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    dim a as integer
    filenam = split (strpath, "\")
    a = ubound (filenam)
    filename = filenam (a)
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    thanks, I totally spaced out the split function!

    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Another way if you want (VB5 friendly!):
    VB Code:
    1. Dim strFile As String
    2. Dim strNew As String
    3. Dim i As Long
    4.  
    5. strFile = Text1.Text
    6.  
    7. Do While Right(strFile, 1) <> "\"
    8.     strNew = strNew & Right(strFile, 1)
    9.     strFile = Left(strFile, Len(strFile) - 1)
    10. Loop
    11.  
    12. strNew = StrReverse(strNew)
    13. List1.AddItem strNew

  5. #5
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    yeah i understand, happens to me all the time. You may have to clean my code up a lil cuz i was too lazy to open up VB to check it.
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  6. #6

  7. #7
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    yeah i think that split is the easiest way though, less code
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    Oh, no big deal, it was just the function I was looking for! Just spaced me. Oh and thanks ChrisJK that looks like taht may work bettere anyways!

    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

Posting Permissions

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



Click Here to Expand Forum to Full Width