943,955 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 3481
  • VB.NET RSS
Mar 4th, 2009
0

How to remove parts of a string

Expand Post »
Hi,
I currently have a string, ie
<TEXT default_lang="en" str="Button text"/> and I want to be able to remove <TEXT default_lang="en" str=" and "/> so I am left with Button Text
If you could help me in any way I would be greatful
thank you
Luke
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lukechris is offline Offline
17 posts
since Aug 2008
Mar 6th, 2009
0

Re: How to remove parts of a string

Here is one way to do it. It assumes that the structure of the string remains the same all the time.
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim StartPoint As Integer = TextBox1.Text.IndexOf("str=")
  3. If StartPoint >= 0 Then
  4. StartPoint += 5
  5. Dim EndPoint = TextBox1.Text.IndexOf("/>", StartPoint)
  6. If EndPoint > StartPoint Then
  7. TextBox2.Text = TextBox1.Text.Substring(StartPoint, EndPoint - 1 - StartPoint)
  8. End If
  9. End If
  10. End Sub
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Mar 6th, 2009
0

Re: How to remove parts of a string

Another way. If your text is in a textbox then click between the "" marks and then press a button. as:
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim StartPoint As Integer = TextBox1.Text.LastIndexOf(Chr(34), TextBox1.SelectionStart) + 1
  3. Dim EndPoint As Integer = TextBox1.Text.IndexOf(Chr(34), TextBox1.SelectionStart)
  4. TextBox2.Text = TextBox1.Text.Substring(StartPoint, EndPoint - StartPoint)
  5. End Sub
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Mar 7th, 2009
0

Re: How to remove parts of a string

hay how are u by using split we can split the string
Reputation Points: 10
Solved Threads: 0
Newbie Poster
silambharasan is offline Offline
17 posts
since Sep 2008
Mar 9th, 2009
0

Re: How to remove parts of a string

That looks like an 'attribute' within an xml file.

Therefore it would be sensible to use consider it as an xml object and use the methods associated with that.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Having problem in the choice in using Query String OR session/cookies
Next Thread in VB.NET Forum Timeline: store the textbox value using loop?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC