Download presentation
Presentation is loading. Please wait.
Published byΘεοφιλά Μαρκόπουλος Modified over 5 years ago
1
BMI Form1 Body Mass Index textBox3-4 (readonly) trackBar1
trackBar1, trackBar2 Form1 Body Mass Index textBox3-4 (readonly) trackBar1 min(400),max(1000) smallchange trackBar2 min(150),max(190) radioButton1 男 checked radioButton2 女 radioButton1,2 label1, …, label4 textBox1, …, textBox4 by Szeto CY Visual C# 2008
2
雙按 (trackBar1,2),並加入以下程式碼:
捲動/拉動 private void trackBar1_Scroll(object sender, EventArgs e) { double wt = trackBar1.Value/10.0; double ht = trackBar2.Value/100.0; double bmi = wt/ht/ht; textBox1.Text = wt.ToString("0.0"); textBox2.Text = ht.ToString("0.0"); textBox3.Text = bmi.ToString("0.00"); calculateBMI(); } 數字轉文字 改變 textBox1,2,3 by Szeto CY Visual C# 2008
3
private void calculateBMI() { int n1=20, n2=25, n3=30;
double wt = double.Parse(textBox1.Text); double ht = double.Parse(textBox2.Text); double bmi = wt/ht/ht; if (radioButton2.checked){ n1--; n2--; n3--; } textBox4.BackColor = Color.Lavender; if (bmi… else if (bmi < n2){ textBox4.Text = "正常"; textBox4.BackColor = Color.LightGreen; else if (bmi… else … 文字轉數字 BMI=wtht² by Szeto CY Visual C# 2008
4
private void Form1_Load(object sender, EventArgs e) {
trackBar1.Value = 550; trackBar2.Value = 165; calculateBMI(); } private void radioButton1_CheckedChanged (object sender, EventArgs e) { calculateBMI(); } private void radioButton2_CheckedChanged (object sender, EventArgs e) by Szeto CY Visual C# 2008
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.