Reputation: 2057
I'm trying the following code but i get zero result!!
textBox13.Text = (int.Parse(textbox1.Text) / 536).ToString ();
Upvotes: 0
Views: 2383
Reputation: 2173
already answerd bu i'd suggest using TryParse
double d = 0;
if(double.TryParse(textbox1.Text,out d))
{
textBox13.Text = (d/536.0).ToString();
}
else
{
MessageBox.Show("There is no valid number in the textbox");
}
Upvotes: 1
Reputation: 223282
I believe you are expecting result set in 0.0...
a double /float number. You may divide by 536.0 or 536d
textBox13.Text = (int.Parse(textbox1.Text) / 536d).ToString ();//or 536.0
Currently your calculation is being done in integer type. You may cast either of the two oprands to type double/float.
Upvotes: 4
Reputation: 40566
That's because you do integer division.
Try
textBox13.Text = (double.Parse(textbox1.Text) / 536).ToString();
Upvotes: 3