Download presentation
Presentation is loading. Please wait.
Published byAdam Helgesen Modified over 5 years ago
1
label1 Name label2 Time (0-23) textBox1 textBox2 textBox3 button1
再按F5開始偵錯 (執行) label1 Name label2 Time (0-23) textBox1 textBox2 textBox3 button1 &Submit form1 Greeting pictureBox1 SizeMode(zoom) txtName txtTime txtMsg 其他屬性: BackColor BackgroundImage MaximumSize Font MinimumSize ForeColor Image SizeMode Enabled Size StartPosition TextAlign Text Visible by Szeto CY Visual C# 2008
2
雙按按鈕(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; } by Szeto CY Visual C# 2008
3
private void button1_Click(object sender, EventArgs e) {
修改程式碼: 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"; else txtMsg.Text = "Good Evening"; txtMsg.Text += " Mr." + txtName.Text; 假若使用者沒有輸入時間,會如何? int hh = int.Parse(txtTime.Text); by Szeto CY Visual C# 2008
4
private void button1_Click(object sender, EventArgs e) { try
修改程式碼: 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"; else txtMsg.Text = "Good Evening"; txtMsg.Text += " Mr." + txtName.Text; by Szeto CY Visual C# 2008
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.