Results 1 to 5 of 5

Thread: help with strings

  1. #1

    Thread Starter
    Addicted Member nota141's Avatar
    Join Date
    Feb 2000
    Location
    The place down there under everyone else.
    Posts
    224
    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)

  2. #2

    Thread Starter
    Addicted Member nota141's Avatar
    Join Date
    Feb 2000
    Location
    The place down there under everyone else.
    Posts
    224

    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)

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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

  4. #4

    Thread Starter
    Addicted Member nota141's Avatar
    Join Date
    Feb 2000
    Location
    The place down there under everyone else.
    Posts
    224

    Post 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)

  5. #5
    Junior Member
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    21

    Wink 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
  •  



Click Here to Expand Forum to Full Width