|
-
Dec 5th, 2000, 05:54 PM
#1
Thread Starter
Addicted Member
i have a string with "\" in it i i wanted a way to only get the last bit of test after the last "\" but the string may contain different numbers of "\" can someone help
On Error wake up and try again ;-)
___________________________
ICQ # 65392645
email - [email protected]
Visual Studio 6 ent with SP5 Running on XP with an AMD 1.2 ThunderBird with 512 MB RAM And a 120GB primary HDD (very sweet)
-
Dec 5th, 2000, 06:25 PM
#2
Thread Starter
Addicted Member
example
two examples on data that i need to change
NDS:\\HUB\APHS\ST\95\gmitchell
NDS:\\HUB\APHS\Staff\twest
i need gmitchell and twest
i was thinking i have some code that will give me the cut the string in to two parts. but i will need a while wend to cheack if the string still contains "\".
On Error wake up and try again ;-)
___________________________
ICQ # 65392645
email - [email protected]
Visual Studio 6 ent with SP5 Running on XP with an AMD 1.2 ThunderBird with 512 MB RAM And a 120GB primary HDD (very sweet)
-
Dec 5th, 2000, 06:36 PM
#3
_______
<?>
Code:
'if you have VB6
Private Sub Form_Load()
Dim x As String
x = "my/and that/and mylast/is not only a / but it was last"
Dim y
y = Split(x, "/")
MsgBox y(UBound(y))
End Sub
Code:
'split function for VB5 and under vb6 has the function
'posted originally by Aaron Young
Public Function Split2(ByVal sString As String, ByVal sSeparator As String) As Variant
Dim sParts() As String
Dim lParts As Long
Dim lPos As Long
lPos = InStr(sString, sSeparator)
While lPos
ReDim Preserve sParts(lParts)
sParts(lParts) = Left(sString, lPos - 1)
sString = Mid(sString, lPos + Len(sSeparator))
lPos = InStr(sString, sSeparator)
lParts = lParts + 1
Wend
If Len(sString) Then
ReDim Preserve sParts(lParts)
sParts(lParts) = sString
End If
Split2 = IIf(lParts, sParts, Array())
End Function
'Example:
Private Sub Form_Load()
Dim x As String
x = "my/and that/and mylast/is not only a / but it was last"
Dim y
y = Split2(x, "/")
MsgBox y(UBound(y))
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Dec 5th, 2000, 06:50 PM
#4
Thread Starter
Addicted Member
the code i found
this is the code that i found all i need to do is put a while wend loop around it to check if there is still "\" in the string.
Code:
result1 = Left$(tempstr, InStr(1, tempstr, "\", vbTextCompare))
tempstr = Right$(tempstr, Len(tempstr) - Len(result1))
result1 = Left$(result1, Len(result1) - 1)
On Error wake up and try again ;-)
___________________________
ICQ # 65392645
email - [email protected]
Visual Studio 6 ent with SP5 Running on XP with an AMD 1.2 ThunderBird with 512 MB RAM And a 120GB primary HDD (very sweet)
-
Dec 6th, 2000, 08:25 AM
#5
Junior Member
solution
It is mucht easier. Just use the function InstrRev.
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
|