Israel

Israel

  • 690
  • 1.3k
  • 219.6k

Alerting message using textboxes than only codes

Oct 15 2016 8:19 AM
Hi!
 
I wrote these codes and work well. What I am doing first before to explain what I need.
As you can see when I put number minus to 5 it's should display a message. For that I do use three textboxes. Two textboxes to put number and the thirth one where the message should appear if the number its minus than 5.
But my big problem is. How can I can use decimal number using textboxes as this:
 
decimal d1, d2, total;
decimal.TryParse(txtBox1.Text, out d1);
decimal.TryParse(txtBox2.Text, out d2);
total = d1 - d2;
txtBox3.Text = total.ToString("N");
 
But the real code is:
 
private void txtBox3_TextChanged(object sender, EventArgs e)
{
string s = (sender as TextBox).Text;
int i = Convert.ToInt16(s);
if (i < 5)
{
MessageBox.Show("The stock is minimum. Thanx!");
(sender as TextBox).Focus();
}
}
 
 
 

Answers (5)