①方法1:
Private Sub Command1_Click()
Dim p As Single
Dim s As Single
Dim r As Single
p = 3.1415 "定義PAI的值
r = Val(Text1)
s = p * r ^ 2 "面積公式
c = 2 * p * r "周長公式
Label2.Caption = c "標籤2輸出周長結果
Text2 = s "文字框2輸出面積結果
End Sub
②方法2
r = InputBox("請輸入一個圓的半徑", "輸入", 0) "獲取輸入值
MsgBox ("圓的面積為:" & s & "圓的周長為:" & c) "輸出結果
①方法1:
Private Sub Command1_Click()
Dim p As Single
Dim s As Single
Dim r As Single
p = 3.1415 "定義PAI的值
r = Val(Text1)
s = p * r ^ 2 "面積公式
c = 2 * p * r "周長公式
Label2.Caption = c "標籤2輸出周長結果
Text2 = s "文字框2輸出面積結果
End Sub
②方法2
Private Sub Command1_Click()
Dim p As Single
Dim s As Single
Dim r As Single
p = 3.1415 "定義PAI的值
r = InputBox("請輸入一個圓的半徑", "輸入", 0) "獲取輸入值
s = p * r ^ 2 "面積公式
c = 2 * p * r "周長公式
MsgBox ("圓的面積為:" & s & "圓的周長為:" & c) "輸出結果
End Sub