Hello. Anybody can suggest whats the best way to trap the null exeption from this code of mine.
For I just popup the error being generated.vb Code:
long last_Sent; long last_Rec; private void timerPackets_Tick(object sender, EventArgs e) { try { string strSent = null; string strReceived = null; long strStatdon; long strStatup; long curr_Sent = 0; long curr_Rec = 0; long speedDown = 0; long speedUp = 0; strSent = clsMethods.strLines(5); strReceived = clsMethods.strLines(4); string[] arrSent = strSent.Split(','); string[] arrRec = strReceived.Split(','); curr_Sent = long.Parse(arrSent[1]); curr_Rec = long.Parse(arrRec[1]); speedDown = curr_Rec - last_Rec; speedUp = curr_Sent - last_Sent; strStatdon = speedDown * 8; strStatup = speedUp * 8; StatusDown.Text = clsMethods.convertSize(strStatdon) + " /s"; StatusUP.Text = clsMethods.convertSize(strStatup) + " /s"; lblUP.Text = clsMethods.convertSize(last_Sent); lblDown.Text = clsMethods.convertSize(last_Rec); last_Rec = long.Parse(arrRec[1]); last_Sent = long.Parse(arrSent[1]); } catch (Exception ex) { MessageBox.Show(ex.ToString(),"Information"); }
On my code sometimes this two line
strSent = clsMethods.strLines(5);
strReceived = clsMethods.strLines(4);
doesn't return a value.
that's why this line
string[] arrSent = strSent.Split(',');
string[] arrRec = strReceived.Split(',');
throw me an exeption.
I want when nullreference error occured just to continue the timer tick until that two line have value in it..
THanks.
br.




Reply With Quote