private void MainForm_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0;
comboBox2.SelectedIndex = 1;
comboBox3.SelectedIndex = 0;
comboBox4.SelectedIndex = 1;
comboBox5.SelectedIndex = 0;
comboBox6.SelectedIndex = 1;
comboBox7.SelectedIndex = 0;
comboBox8.SelectedIndex = 1;
}
private void button4_Click(object sender, EventArgs e)
{
string str1, str2;
str1=Convert.ToString(comboBox7.SelectedItem);
str2=Convert.ToString(comboBox8.SelectedItem);
double d1, d2;
if (textBox7.Text == "")
{
textBox7.Text = "1";
d1 = 1;
}
else
d1 = Convert.ToDouble(textBox7.Text);
if (str1 == str2)
{
d2 = d1;
textBox8.Text = Convert.ToString(d2);
}
else
{
if(str1 == "摄氏度" && str2 == "华氏度")
{
d2=1.8*d1+32;
textBox8.Text = Convert.ToString(d2);
}
if(str1 == "摄氏度" && str2 == "开氏度")
{
d2=d1+273.15;
textBox8.Text = Convert.ToString(d2);
}
if(str1 == "华氏度" && str2 == "摄氏度")
{
d2=(d1-32)/1.8;
textBox8.Text = Convert.ToString(d2);
}
if(str1 == "华氏度" && str2 == "开氏度")
{
d2=(d1-32)/1.8+273.15;
textBox8.Text = Convert.ToString(d2);
}
if (str1 == "开氏度" && str2 == "摄氏度")
{
d2 = d1 - 273.15;
textBox8.Text = Convert.ToString(d2);
}
if (str1 == "开氏度" && str2 == "华氏度")
{
d2 = (d1 - 273.15) * 1.8 + 32;
textBox8.Text = Convert.ToString(d2);
}
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != '\b' && e.KeyChar != 46)//允许输入退格键和小数点键
{
if ((e.KeyChar < '0') || (e.KeyChar > '9'))//允许输入0-9数字
{
e.Handled = true;
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有