40 likes | 54 Views
按照下表,更改各控制項 Text 屬性 再按 F5 開始偵錯 ( 執行 ). 其他屬性 : BackColor BackgroundImage MaximumSize Font MinimumSize ForeColor Image SizeMode Enabled Size StartPosition TextAlign Text Visible. 雙按按鈕 (Submit) ,並加入以下程式碼:. private void button1_Click(object sender, EventArgs e) {
E N D
按照下表,更改各控制項Text屬性 再按F5開始偵錯 (執行) 其他屬性: BackColor BackgroundImage MaximumSize Font MinimumSize ForeColor Image SizeMode Enabled Size StartPosition TextAlign Text Visible Visual C# 2008
雙按按鈕(Submit),並加入以下程式碼: private void button1_Click(object sender, EventArgs e) { txtMsg.Text = " Mr." + txtName.Text; } 右按,選檢視程式碼,修改程式碼: private void button1_Click(object sender, EventArgs e) { int hh = int.Parse(txtTime.Text); txtMsg.Text = hh.ToString("00"); } 修改程式碼: private void button1_Click(object sender, EventArgs e) { int hh = 999; txtMsg.Text = txtName.Text + hh; } Visual C# 2008
修改程式碼: private void button1_Click(object sender, EventArgs e) { int hh = int.Parse(txtTime.Text); } if (hh < 12)txtMsg.Text = "Good Morning"; else if (hh < 18)txtMsg.Text = "Good Afternoon"; elsetxtMsg.Text = "Good Evening"; txtMsg.Text += " Mr." + txtName.Text; 假若使用者沒有輸入時間,會如何? int hh = int.Parse(txtTime.Text); Visual C# 2008
修改程式碼: private void button1_Click(object sender, EventArgs e) { try { int hh = int.Parse(txtTime.Text); } catch { txtMsg.Text = "Error"; } } if (hh < 12)txtMsg.Text = "Good Morning"; else if (hh < 18)txtMsg.Text = "Good Afternoon"; elsetxtMsg.Text = "Good Evening"; txtMsg.Text += " Mr." + txtName.Text; Visual C# 2008