How to remove parts of a string

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 16
Reputation: lukechris is an unknown quantity at this point 
Solved Threads: 0
lukechris lukechris is offline Offline
Newbie Poster

How to remove parts of a string

 
0
  #1
Mar 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: How to remove parts of a string

 
0
  #2
Mar 6th, 2009
Here is one way to do it. It assumes that the structure of the string remains the same all the time.
  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
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: How to remove parts of a string

 
0
  #3
Mar 6th, 2009
Another way. If your text is in a textbox then click between the "" marks and then press a button. as:
  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
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 12
Reputation: silambharasan is an unknown quantity at this point 
Solved Threads: 0
silambharasan silambharasan is offline Offline
Newbie Poster

Re: How to remove parts of a string

 
0
  #4
Mar 7th, 2009
hay how are u by using split we can split the string
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: How to remove parts of a string

 
0
  #5
Mar 9th, 2009
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.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC