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. :)
Printable View
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. :)
VB Code:
Debug.Print Mid$(MyString, InStrRev(MyString, "\") + 1)
Thanks, but I tried that and it doesn't work lol.
???
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
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)
Thanks a lot penagate, it worked a charm. :)
Oh and thanks to Piller for contributing as well. :)
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.