How to pick out a specified text from a text box?

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 1
Reputation: kevinlin is an unknown quantity at this point 
Solved Threads: 0
kevinlin kevinlin is offline Offline
Newbie Poster

How to pick out a specified text from a text box?

 
0
  #1
Jun 23rd, 2008
HI, all, I want to ask a question as what I described in the topic.
For example, now I have some data in the text box, such like :

$VTG,,,,,,,,,N*30
$GGA,,,,,,0,00,99.99,,,,,,*48
$GSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GSV,1,1,00*79
$GLL,,,,,,V,N*64
$ZDA,,,,,00,00*48
$GSV,,,,,,,,,,00*67
.
.
.
.
.

From all these data, what I want is only the string starts with $GSV, so how can I pick this kind of string out and put them into another textbox?Should I save all these data first and use the StreamReader to read each line of the saved file?

Thank you for your kind helping~!
Last edited by kevinlin; Jun 23rd, 2008 at 3:57 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: How to pick out a specified text from a text box?

 
0
  #2
Jun 23rd, 2008
First take your textbox's text in string apply your regular expression pattern to extract your interseting part in that string.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 4
Reputation: Dabuskol is an unknown quantity at this point 
Solved Threads: 0
Dabuskol Dabuskol is offline Offline
Newbie Poster

Re: How to pick out a specified text from a text box?

 
0
  #3
Jun 25th, 2008
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (line.Substring(0,4) == "$GSV")
{
Textbox1.Test = line.
}
}
}
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 345
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 44
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: How to pick out a specified text from a text box?

 
0
  #4
Sep 4th, 2008
Originally Posted by Dabuskol View Post
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (line.Substring(0,4) == "$GSV")
{
Textbox1.Test = line.
}
}
}
I Know this is an old post, and I'm sure the problem has been handled, but actually a better way would not be so save it to a file and then re open it with streamReader, the original question said they started with the text in a text box, so best would be a stringreader

  1. using (StringReader sr = new StringReader(Textbox1.Text))
  2. { string line;
  3. while((line =sr.ReadLine())!= null)
  4. {if (line.Substring(0,4) == "$GSV")
  5. {
  6. Textbox2.Text = line;
  7. }
  8. }
  9. }
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC