private void buttonSetRegion_Click(object sender, EventArgs e) { byte dminfre, dmaxfre; int band = 2; if (radioButtonChineeseBand2.Checked) { band = 1; } if (radioButtonUSBand.Checked) { band = 2; } if (radioButtonChineeseBand.Checked) { band = 3; } if (radioButtonUEBand.Checked) { band = 4; } dminfre = Convert.ToByte(((band & 3) << 6) | (comboBoxDminfre.SelectedIndex & 0x3F)); dmaxfre = Convert.ToByte(((band & 0x0c) << 4) | (comboBoxDmaxfre.SelectedIndex & 0x3F)); try { ErrorsCatcher.errorName = RWDev.SetRegion(ref RWDev.comAddress, dmaxfre, dminfre, RWDev.frmComPortIndex); if (ErrorsCatcher.errorName != 0) { string strLog = "Set region failed " + ErrorsCatcher.GetReturnCodeDesc(ErrorsCatcher.errorName) + Environment.NewLine; richTextBoxLogs.AppendText(strLog); return; } else { string strLog = "Set region success" + Environment.NewLine; richTextBoxLogs.AppendText(strLog); } } catch { richTextBoxLogs.AppendText("Set region dailed" + Environment.NewLine); } }