Results 1 to 8 of 8

Thread: Do NOT read this post! Definately NOT!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    27

    Exclamation

    hmm... you DID read it... you (@$*!

    well then i'll ask my question:

    lets say i have a string like "http://www.abc.com/~def/ghi/Text.txt"
    and i want to have the text.txt filtered out of the string.
    But, the string can be modified by the user.. so it can be different...
    like "http://www.def.cah.ter.r/i~gnudie/gi8/35t/avc/Test.asp" and then i want the Test.asp filtered out.

    How do i do this?

    Thanks in advance.
    Life's hard, but the front of a train is harder

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    [list=1][*]Read this[*]If you have VB 6 then use Split Function
    Code:
        Dim strString As String: strString = "http://www.def.cah.ter.r/i~gnudie/gi8/35t/avc/Test.asp"
        Dim myArray() As String
        
        myArray = Split(strString, "/", , vbTextCompare)
        MsgBox myArray(UBound(myArray))
    [/list=1]
    Post #502

  3. #3
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Thumbs up

    As long as there is always a "/" in front of what you want to filter out, this would work:
    Code:
    Private Sub Command1_Click()
    
    Dim TestString As String
    
    TestString = "http://www.abc.com/~def/ghi/Text.txt"
    
    Do Until Right(TestString, 1) = "/"
        TestString = Left(TestString, Len(TestString) - 1)
    Loop
    
    Debug.Print TestString
    
    End Sub

  4. #4
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    DrewDog: it seems to do something opposite. It will return everything but the "Text.txt" part. You could fix it this way:
    Code:
    Dim TestString As String
    Dim orgString As String '//org = original
    
    TestString = "http://www.abc.com/~def/ghi/Text.txt"
    orgString = TestString
    
    Do Until Right(TestString, 1) = "/"
        TestString = Left(TestString, Len(TestString) - 1)
    Loop
    
    Debug.Print Right(orgString, Len(orgString) - Len(TestString))
    Post #503

  5. #5
    Guest
    Try:

    Code:
    OpenFile = "http://www.def.cah.ter.r/i~gnudie/gi8/35t/avc/Test.asp"
    MyFileName = Right$(OpenFile, Len(OpenFile) - InStrRev(OpenFile, "\"))
    
    MsgBox (MyFileName)

  6. #6
    Guest
    you made one small mistake Megatron
    Code:
    OpenFile = "http://www.def.cah.ter.r/i~gnudie/gi8/35t/avc/Test.asp"
    MyFileName = Right$(OpenFile, Len(OpenFile) - InStrRev(OpenFile, "\")) ' mistake is right here 
    'it should be a forward slash
    
    MsgBox (MyFileName)

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    27

    Thumbs up Wow!

    Thnx QWERTY, DrewDog_21, Megatron & denniswrenn for your replies!
    (Never thought there would be a reply so fast, let alone more replies hehe)

    I'll try them out, i'm convinced atleast one will work... thnx everybody!
    Life's hard, but the front of a train is harder

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    27
    Oh, and QWERTY, sorry for the title of the post
    Life's hard, but the front of a train is harder

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