我只是想知道如何使用在整個程序中的更新速度。這裏是我到目前爲止的代碼以供參考......更新我的貨幣轉換費率C#
//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方法是過於空泛,在節目開始時獲取率和我只是一個學生的學習簡單的編程。但是當我再次按相同的轉換時,我仍然需要知道如何使用更新的速率。如果沒有足夠的信息,我可以幫助你獲得更多的編碼
提示:使用數據庫存儲更改率 – wudzik
喜歡什麼樣的? – user2610573
爲了您的目的,它可以是.sdf文件。 http://stackoverflow.com/questions/1121917/local-database-i-need-some-examples – wudzik