Results 1 to 9 of 9

Thread: [RESOLVED] string manipulation help

Hybrid View

  1. #1
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: string manipulation help

    There are multiple ways of parsing so here one:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim sText As String
    3. Dim res1$, res2$
    4.  
    5.     sText = "123456 - Popo"
    6.     res1 = Trim(Left(sText, InStr(1, sText, "-") - 1))
    7.     res2 = Trim(Mid(sText, InStr(1, sText, "-") + 1))
    8.    
    9.     Debug.Print res1
    10.     Debug.Print res2
    11.  
    12. End Sub

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Location
    Philippines
    Posts
    177

    Re: string manipulation help

    Quote Originally Posted by RhinoBull
    There are multiple ways of parsing so here one:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim sText As String
    3. Dim res1$, res2$
    4.  
    5.     sText = "123456 - Popo"
    6.     res1 = Trim(Left(sText, InStr(1, sText, "-") - 1))
    7.     res2 = Trim(Mid(sText, InStr(1, sText, "-") + 1))
    8.    
    9.     Debug.Print res1
    10.     Debug.Print res2
    11.  
    12. End Sub
    i got an error in this with this example string "123456 - Popo-Cost"
    result1 = "123456 - Popo"
    result2 = "Cost"

    the result must be
    result1 = "123456"
    result2 = "Popo-Cost"

    cheers

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