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

I have a string and in that string I am passing value like this
"FR-0612-037320-CHARITY REF 006 0600051970001"

I would like to assign same string to another string but value should be
"FR-0612-037320-CHARITY REF 006"

I mean the last word should be avoided, how should I do this?

Please help me from this issue
Posted
Updated 18-Nov-11 23:56pm
v2
Comments
Sergey Alexandrovich Kryukov 19-Nov-11 18:07pm    
Are you banned with on-line MSDN? :-)
--SA

Try this:
VB
Dim line As String = "FR-0612-037320-CHARITY REF 006 0600051970001";
Dim secondLine As String;

secondLine = line.SubString(0,line.LastIndexOf(" "))
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 19-Nov-11 18:06pm    
Enough said, a 5.
--SA
André Kraak 19-Nov-11 19:07pm    
Thanks.
Above answer already Solved your Question.
I am just giving the Function which will Solve your Problem.
VB
Public Function GetSubString(Bvyal S1 as String)As String
     Return (S1.Remove(S1.LastIndexOf(" ")))
End Sub

Just Call above Function by passing your String as Parameter
VB
MesageBox.Show(GetSubString("FR-0612-037320-CHARITY REF 006 0600051970001"))
 
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