How to make programmable thermometer by C# | Code
For Fahrenheit to Centigrade we set the value of Fahrenheit from track
bar and convert this value into Centigrade using this formula C= (F-32)*(5/9).
private void trackBar1_Scroll(object sender, EventArgs e)
{
maskedTextBox1.Text =
(trackBar1.Value).ToString();
double change = (trackBar1.Value - 32) * (5.0 / 9.0);
change = Math.Round(change, 2);
maskedTextBox2.Text =
change.ToString();
}
For
Centigrade to Fahrenheit we set the value of Centigrade from track bar and
convert this value into Fahrenheit using this formula F= (C* (9/5)) +32.
private void trackBar2_Scroll_1(object sender, EventArgs e)
{
maskedTextBox3.Text =
(trackBar2.Value).ToString();
maskedTextBox4.Text =
((trackBar2.Value * (9.0 / 5.0)) + 32).ToString();
}
No comments:
Post a Comment