用vb编写程序,输入半径,计算圆周长和圆面积

2024-11-16 19:51:55
推荐回答(1个)
回答(1):

Const PI = 3.14159
Dim r As Double
Dim C As Double
Dim S As Double

If IsNumeric(Text1.Text) Then
r = Val(Text1.Text)
C = 2 * PI * r
S = PI * r ^ 2

Text2.Text = Format(C, "0.00")
Text3.Text = Format(S, "灶则0.00")
Else
MsgBox "输入不饥辩宏是一个烂册有效的数值。", vbCritical
Text1.SetFocus
End If