eneate
asked on
how do i split a string to get the text after the last \ symbol - vb6
Hi
Usinf vb 6 how would i split a string that looked like c:\test\ghtf\jsjghdj to get all of the text after the last \ symbol. The length of the string and the number of these strings could vary
Thanks
Usinf vb 6 how would i split a string that looked like c:\test\ghtf\jsjghdj to get all of the text after the last \ symbol. The length of the string and the number of these strings could vary
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dim tail as string
tail = mid("\"+YourString,Instrre v("\"+Your String,"\" )+1)
tail = mid("\"+YourString,Instrre
Try this:
Dim str1 As String
Dim str2 As String
str1 = "c:\test\ghtf\jsjghdj"
str2 = StrReverse(str1)
str2 = StrReverse(Left(str2, InStr(1, str2, "\") - 1))
Alternatively:
Dim strText As String
Dim p As Integer
Dim strLastBit As String
strText = "c:\test\ghtf\jsjghdj"
p = InStrRev(strText, "\")
strLastBit = Mid$(strText, p + 1)
Looks like some good solutions. The way I do it is
For X = Len(S) to 1 Step -1
If Mid$(S,X,1) = "\" Then
P = X
Exit For
End if
Next X
E = Mid$(S, P + 1)
where S is your initial string, X and P are intergers, and E is a string to hold the end of S after the \.
For X = Len(S) to 1 Step -1
If Mid$(S,X,1) = "\" Then
P = X
Exit For
End if
Next X
E = Mid$(S, P + 1)
where S is your initial string, X and P are intergers, and E is a string to hold the end of S after the \.
ASKER
Thanks it works fine. Thanks to everyone else who contributed.
Open in new window