wrote:
string[] a = null;
if (e.KeyChar == (char)13)
{
a = textBox1.Text.Split('\n');
textBox2.Text = Convert.ToString(i);
}
A lot of this code is hideous. Use Keys.Enter, not 13. Use Environment.NewLine, not \n. You can iterate over a, and count how many of the strings are not empty, to get the result you want.
You've edited your question, but nothing you've said makes much sense to me. Did you try what I said ? It's the only solution. You need to count how many lines are not empty.