basic 2720 2193 for both amt i use text box.
2193 how i get it means (2720/31)*25
2266 how i get it means (2720/30)*25
how to do the above one.suppose if i type 31 means 2193 to be arrived
and if i type 30 means 2266 to be arrived in the textbox.
rgds,
Narasiman P
Loading
Roy SPosted Jul 9, 2012, 6:06 PM
I think you want a textbox where you can enter a number being that 30 or 31 (others are also possible?) and then you click a button (or it happens while you type?) and the correct number should appear in another textbox.
Adding the controls should be easy and straightforward (dragging from the toolbox), as well as adding the event to the button (double click the button in the designer). The code should also be easy:
private void button_clicked(EventArgs e)
{
int input;
if (int.TryParse(txtInput.Text, out input))
{
txtOutput.Text = ((25 * 2720) / input).ToString();
}
}
In your example it seems that you keep the decimal points after dividing so 2720 or the input should be converting to a float/decimal to et the correct result. Or you can do it as in my example where I just switched the operators around to avoid rounding errors.