コード例 #1
0
        private void RdbUStoNT_CheckedChanged(object sender, EventArgs e)
        {
            if (RdbUStoNT.Checked)
            {
                int    dollor = 0;
                double rate   = 0;
                double result = 0;
                string msg    = "";
                try
                {
                    dollor = Convert.ToInt32(TxtDollor.Text);
                }
                catch
                {
                    MessageBox.Show("請輸入金額", "注意", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    RdbUStoNT.Checked = false;
                    TxtDollor.Focus();
                    return;
                }

                try
                {
                    rate = Convert.ToDouble(TxtRate.Text);
                }
                catch
                {
                    MessageBox.Show("請輸入美金匯率", "注意", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    RdbUStoNT.Checked = false;
                    TxtRate.Focus();
                    return;
                }

                result      = dollor * rate;
                msg         = "美金" + dollor.ToString("f2") + "元可兌換成台幣" + result.ToString("f2") + "元";
                LblMsg.Text = msg;
            }
        }
コード例 #2
0
 private void TxtDollor_Enter(object sender, EventArgs e)
 {
     TxtDollor.Clear();
 }