Click here to Skip to main content
15,790,135 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:

I have
Textbox1.text= "Kumar, Ravi (Customer - Back office) - C088888"

I want to fetch "C088888" from above string wherein it is followed by last " - " string.Please let me know how can i get this ?

Thanks & Regards
Care Career
Updated 6-Aug-12 20:07pm

1 solution


try this code. I tested it on your string and got your desired result:
Private Sub Form1_Load(sender As Object, e As EventArgs)
    Textbox1.Text = "Kumar, Ravi (Customer - Back office) - C088888"
    Dim res As String() = Textbox1.Text.Split("-"C)
    If res.Length >= 2 Then
        Dim number As String = res(res.Length - 1).Replace(" ", "")
    End If
End Sub
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900