| | |
How to pick out a specified text from a text box?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 1
Reputation:
Solved Threads: 0
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~!
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.
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
•
•
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (line.Substring(0,4) == "$GSV")
{
Textbox1.Test = line.
}
}
}
C# Syntax (Toggle Plain Text)
using (StringReader sr = new StringReader(Textbox1.Text)) { string line; while((line =sr.ReadLine())!= null) {if (line.Substring(0,4) == "$GSV") { Textbox2.Text = line; } } }
![]() |
Similar Threads
- How can i pick date in PHP (PHP)
- for validation - text box and drop down menu (JavaScript / DHTML / AJAX)
- link color (HTML and CSS)
- Obtain Remote Assistance by Sending an E-mail Message in Windows XP (Windows tips 'n' tweaks)
- Windows message box "Restore" when windows 98 loads (Viruses, Spyware and other Nasties)
- DOS issue (Windows NT / 2000 / XP)
- Obtain Remote Assistance by Sending an E-mail Message in Windows XP (Windows tips 'n' tweaks)
- Cannot enter any text in a IE text-box (Viruses, Spyware and other Nasties)
- Virus, Adware, or just explorer causing malfunctions-res://mshp.dll/http_404.htm (Viruses, Spyware and other Nasties)
Other Threads in the C# Forum
- Previous Thread: Are Text elements in Revit accessible in C#?
- Next Thread: need help!..
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






