程式列表如下
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim A1, B1, C1 As Single
A1 = Val(TextBox1.Text)
B1 = Val(TextBox2.Text)
C1 = A1 + B1
Label3.Text = C1.ToString
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim A1, B1, C1 As Single
A1 = Val(TextBox3.Text)
B1 = Val(TextBox4.Text)
C1 = A1 - B1
Label7.Text = C1.ToString
End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
Dim A1, B1, C1 As Single
A1 = Val(TextBox8.Text)
B1 = Val(TextBox7.Text)
C1 = A1 * B1
Label11.Text = C1.ToString
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
Dim A1, B1, C1 As Single
A1 = Val(TextBox6.Text)
B1 = Val(TextBox5.Text)
C1 = A1 / B1
Label8.Text = C1.ToString
End Sub
Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
Dim W, H, BMI As Single
W = Val(TextBox9.Text) '體重公斤
H = Val(TextBox10.Text) '身高公分
H = H / 100 '身高變成公尺單位
BMI = W / Math.Pow(H, 2)
Label16.Text = BMI.ToString
End Sub
Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
Dim A1, B1, C1, Ans, I As Single
Dim S1 As String
A1 = Val(TextBox11.Text)
B1 = Val(TextBox12.Text)
C1 = Val(TextBox13.Text)
S1 = " , "
Ans = 0
For I = A1 To B1 Step C1
Ans += I
Label23.Text = Label23.Text + S1 + I.ToString
Label25.Text = Label25.Text + S1 + Ans.ToString
Next
Label22.Text = Ans.ToString
End Sub
End Class
沒有留言:
張貼留言