Private Sub Form_click()
Dim r As Single '定义半径r为单精度(变量)
Const PI As Single = 3.14 '定义PI为单精度(常量)
Dim s As Single '定义面积S为单精度(变量)
r = InputBox("输入r") '半径r通过inputbox函数输入值
s = PI * r ^ 2 '用求圆面积公式,并把值赋给S
Print s '在窗体上打印出S的值
End Sub
'直接复制此代码到代码区 然后点一下窗体输入任意一个数值即得出圆的面积
Private Sub Form_Click()
Dim x As Integer, PI As Single
PI = 3.1415926
x = InputBox("输入一个圆的半径")
y = 3.14 * x * x
MsgBox "圆的面积为:" & y
End Sub
"两个commandbutton 两个lable 两个text"
Private Sub Command1_Click()
r = Text1.Text
p = 3.14
s = p * r * r
Text2.Text = s
Private Sub Command2_Click()
End
Private Sub Text1_LostFocus()
Cls
r = Text1.Text
Circle (10000, 3000), r, vbBlack
If r > 3000 Then
MsgBox "溢出!"
Else
If r <= 0 Then
MsgBox "半径不能为0!"
End If
End If
End Sub