注册 登录
编程论坛 C# 论坛

新人求鉴定设定按钮代码写得对不对?

Elijingo 发布于 2016-10-27 15:38, 1785 次点击
就是事先选择好某个数值,然后按设定按钮。
是有串口指令的。
   
private void button3_Click(object sender, EventArgs e)
        {
             Thread.Sleep(500);
            if (comboBox5.Text == "2400")
                hexSend("FC00990607");
            else if (comboBox5.Text == "4800")
                hexSend("FC00990606");
            else if (comboBox5.Text == "9600")
                hexSend("FC00990601");
            else if (comboBox5.Text == "19200")
                hexSend("FC00990602");
            else if (comboBox5.Text == "38400")
                hexSend("FC00990603");
            else
                hexSend("FC00990604");

        }
1 回复
#2
over12302016-10-28 08:28
这种情况下,用swith 语句呀。
这样写你把{} 加上,结果更清晰,更不容易出错。
1