|
-
Aug 6th, 2000, 07:53 PM
#1
Thread Starter
Junior Member
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 
-
Aug 6th, 2000, 08:00 PM
#2
Fanatic Member
[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
-
Aug 6th, 2000, 08:01 PM
#3
Hyperactive Member
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
-
Aug 6th, 2000, 08:22 PM
#4
Fanatic Member
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
-
Aug 7th, 2000, 07:32 AM
#5
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)
-
Aug 7th, 2000, 09:31 AM
#6
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)
-
Aug 7th, 2000, 10:46 AM
#7
Thread Starter
Junior Member
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 
-
Aug 7th, 2000, 10:48 AM
#8
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|