VB BMI 計算測試


Public Class Form1

 
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 End Sub

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 Dim hight, weight, tmp As Double
 Dim ans As Integer
 If TextBox1.Text = "" Then
 MessageBox.Show("請填身高")
 End If
 If TextBox2.Text = "" Then
 MessageBox.Show("請填體重")
 End If
 If TextBox1.Text <> "" Then
 If TextBox2.Text <> "" Then
 hight = CDbl(TextBox1.Text)
 weight = CDbl(TextBox2.Text)
 tmp = hight / 100
 ans = weight / (tmp * tmp)
 Label4.Text = ans
 End If
 End If
 If RadioButton1.Checked = True Then
 If ans < 18 Then
 Label4.Text += "過輕"
 ElseIf ans < 24 Then
 Label4.Text += "正常"
 ElseIf ans >= 24 Then
 Label4.Text += "過重"
 End If
 End If
 If RadioButton2.Checked = True Then
 If ans < 18 Then
 Label4.Text += "過輕"
 ElseIf ans < 24 Then
 Label4.Text += "正常"
 ElseIf ans >= 24 Then
 Label4.Text += "過重"
 End If
 End If
 End Sub
End Class
文章標籤
全站熱搜
創作者介紹
創作者 Jarvis 的頭像
Jarvis

Jarvis Blog

Jarvis 發表在 痞客邦 留言(0) 人氣(583)