我只想知道如何在整个程序中使用更新的速率。到目前为止,这是我的代码供参考...
//Form 1
private void update_Click(object sender, EventArgs e)
{
if (fromcountry.Text == tocountry.Text)
{
MessageBox.Show(" Please Choose Two Different Currencies To Use This Function", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
btnconvert.Enabled = true;
Exchange_Rate frm = new Exchange_Rate();
frm.Show(this);
}
}
//Form 1 one of the comboboxes for selecting 2nd country
private void tocountry_SelectedIndexChanged(object sender, EventArgs e)
{
btnupdate.Enabled = true;
btnconvert.Enabled = true;
txtvalue.Enabled = true;
exchange();
}
private void exchange()
{
if (fromcountry.Text == tocountry.Text)
{
lblexchange.Text = "1";
}
else if (fromcountry.Text == "SGD - Singapore Dollar" && tocountry.Text == "USD - US Dollar")
{
lblexchange.Text = "1.26";
}
else if (fromcountry.Text == "SGD - Singapore Dollar" && tocountry.Text == "MYR - Malaysian Ringgit")
{
lblexchange.Text = "2.35";
}
else if (fromcountry.Text == "SGD - Singapore Dollar" && tocountry.Text == "EUR - Euro")
{
lblexchange.Text = "0.60";
}
//Form 2
private void btnok_Click(object sender, EventArgs e)
{
try
{
double exchange;
exchange = Double.Parse(txtcurrent.Text);
var frm = (currencyconverter)this.Owner;
frm.PassValue(txtcurrent.Text);
this.Close();
}
catch
{
MessageBox.Show("Please Enter Numbers", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtcurrent.Text = "";
}
}
我知道通过使用 if-else 方法在程序开始时获得费率太模糊了,我只是一个学习简单编程的学生。但是当我再次按下相同的转换时,我仍然需要知道如何使用更新的汇率。如果没有足够的信息,我可以帮助您获得更多编码