private void button2_Click(object sender, EventArgs e) { if (OldGold.Text == "" || P1.Text == "" || P2.Text == "" || NewGold.Text == "") { MessageBox.Show("Enter the missing"); OldGold.Focus(); } else { float OldGold1 = float.Parse(OldGold.Text); float Price1 = float.Parse(P1.Text); float Price2 = float.Parse(P2.Text); int i = 0; float NewGold1 = float.Parse(NewGold.Text); while (true) { if (OldGold1 < NewGold1) { OldGold1 *= Price1 * Price2; } else { break; } i++; } redobox.Text = i.ToString(); } }