|
-
May 6th, 2006, 03:57 PM
#1
Thread Starter
Lively Member
Cutting Strings
Hi,
Ok, I have this string:
VB Code:
Dim MyString As String
MyString = "C:\Project\code.cpp"
I need to know how to remove the pathway in the string and leave just the filename.
If anyone could help I'd appreciate it.
-
May 6th, 2006, 04:02 PM
#2
Re: Cutting Strings
VB Code:
Debug.Print Mid$(MyString, InStrRev(MyString, "\") + 1)
-
May 7th, 2006, 04:40 AM
#3
Thread Starter
Lively Member
Re: Cutting Strings
Thanks, but I tried that and it doesn't work lol.
???
-
May 7th, 2006, 05:22 AM
#4
Addicted Member
Re: Cutting Strings
Hes code works fine for me. Here is another way you can do it, using the Split function.
VB Code:
Private Sub Form_Load()
Dim MyString As String
Dim strSplit() As String
MyString = "C:\Project\code.cpp"
strSplit = Split(MyString, "\")
MsgBox strSplit(UBound(strSplit))
End Sub
Are we alive or just breathing?
-
May 7th, 2006, 05:24 AM
#5
Re: Cutting Strings
Check out my URL/Path Manipulation functions 
Should be a few there that can help you out.
I think:
VB Code:
MsgBox RemoveRootName(MyString, True)
-
May 7th, 2006, 12:40 PM
#6
Thread Starter
Lively Member
Re: Cutting Strings
Thanks a lot penagate, it worked a charm. 
Oh and thanks to Piller for contributing as well.
-
May 7th, 2006, 12:45 PM
#7
Re: Cutting Strings
what was wrong with the solution I suggested? How was it not working? Penagate's code might be a bit of overkill in your situation.
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
|