已知圆半径和圆柱的高,计算圆柱体积和表面积。
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Const PI = 3.14159
Dim r As Integer, h As Integer
Dim t As Single, s As Single
r = Val(TextBox1.Text)
h = Val(TextBox2.Text)
t = PI * r * r * h
s = 2 * PI * r * h + 2 * PI * r * r
Label3.Text = "体积=" & Format(t, "0.000")
Label4.Text = "表面积=" & Format(s, "0.000")
End Sub
End Class