Click here to Skip to main content
15,894,825 members

Comments by HAOYE850815 (Top 5 by date)

HAOYE850815 2-Nov-11 17:13pm View    
Sorry, I am not fully understand- what is the answer number?
HAOYE850815 2-Nov-11 16:47pm View    
Actually I programmed the event for myself. The entry condition is all right when I have tested. Could you please tell if you can find any problems on the events, particularly the register. Is there any problem if I write two events using one same delegate.many thanks for your reply
HAOYE850815 2-Nov-11 16:35pm View    
I am so sorry, It is a typo mistake. I have changed it.

Could you please help me to have a look the event registration? I am not sure why only one event triggered. It bothered me for several days. Many thanks.
HAOYE850815 28-Feb-11 6:12am View    
Hello SA,

Thanks for your reply. Actually what I want is to split the string of $GNGGA data into different substrings, and then extract the usful information(some substrings in this string).
But i found that, because the split method split strings into many substrings and stored line by line, with 0-based index. If I tried to display it in Console Program, it is all right like StreamReader sr = new StreamReader("data1.txt");
string data = sr.ReadToEnd();
string[] lineArr = data.Split('$');
for (int i = 0; i < lineArr.Length; i++)
{
string strTemp = lineArr[i];
string[] words = strTemp.Split(',');
if (words[0] == "GPGGA")
{
try
{
Console.WriteLine(words[1]);
Console.WriteLine(words[2]);
Console.WriteLine(words[4]);
}
catch
{
}
}
}
but the situation is changed if i want to output into WindowsForm TextBox, I used anther function to packed this data processing
private static double GetLat (string sentence)
{
string[] words = sentence.Split(',');
foreach (string s in words)
{
double latitude = Convert.ToDouble(s[2]);
}
return latitude;
}
to split the strings and output the THIRD value, it doesn't work and always break like "Index was outside the bounds of the array". I understand this possibly a simple problem, but it really disturbed me for a few days. can you provide any more suggestions or usful code explanations? Many thanks.
HAOYE850815 8-Feb-11 9:30am View    
Hello Andrew, thanks for your reply. I changed the code as what you said. But the situation is the program is stopped without any reaction. I am not sure, it still no data on the textBox?
// open the serial port
port->Open();
// create a file to write
String^ txt = port->ReadLine(); StreamWriter^ sw = gcnew StreamWriter("GPSdata.txt");
//TextBox1->Text += txt + "\r\n";
while (( txt = port->ReadLine())!= nullptr)
{
//String^ txt = port->ReadLine();
//sw->WriteLine(txt);
TextBox1->Text += txt + "\r\n";
sw->WriteLine(txt);
sw->Flush();
}
//sw->Close();