sppk.net
当前位置:首页 >> 计算圆的面积vB代码 >>

计算圆的面积vB代码

试试这个:Private Sub Form_Load() Dim r, s As Long r = Val(InputBox("请输入圆的半径", "计算圆的面积", 1)) s = 3.14 * r * r Print "圆的面积是:"; s End Sub

这个应该很简单啊. 新建一程序,在窗体上拖入一按钮.然后到代码区,删除其它所有代码后.粘贴以下代码即可.Option ExplicitPrivate Const PI = 3.14Private Sub Command1_Click() Dim R As Double R = InputBox("请输入圆的半径:", "数据输入", "2") If R <= 0 Then MsgBox "半径不能小于或等于0" Else MsgBox "半径为" & R & "的圆的面积是:" & PI * R * R End IfEnd Sub

private sub command1_click()d = inputbox("请输入圆的直径")s = 3.1415926 / 4 * d ^ 2l = 3.1415926 * dmsgbox ("圆的面积" & s & vbcrlf & "圆的周长" & l)end subprivate sub command2_click()r = inputbox("请输入圆的半径")s = 3.1415926 * (r ^ 2)l = 2 * 3.1415926 * rmsgbox ("圆的面积" & s & vbcrlf & "圆的周长" & l)end sub

Dim r, s, c As Integer Private Sub Command1_Click() r = Val(Text1.Text) s = 3.1415926 * r ^ 2 c = 2 * 3.1415926 * r Label1.Caption = "周长是:" & c Label2.Caption = "面积是:" & s End Sub Private Sub Command2_Click() Text1.Text = "" Label1.Caption = "" Label2.Caption = "" 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

Private Sub Command1_Click() Const pi = 3.1415926 r = Val(InputBox("输入半径:")) If r >= 0 Then s = pi * r ^ 2 MsgBox "以" & r & "厘米为半径的圆面积为" & s & "平方厘米" Else MsgBox "输入错误" End If End Sub

Const pi As Double = 3.141592Private Sub Form_Resize() Dim rad As Integer Dim area As Double Dim pre As Double rad = 10 area = pi * rad * rad pre = 2 * pi * rad Print "半径="; rad Print "圆面积="; area Print "圆周长="; preEnd Sub

Private Sub Command1_Click() D = InputBox("请输入圆的直径") S = 3.1415926 / 4 * D ^ 2 L = 3.1415926 * D MsgBox ("圆的面积" & S & vbCrLf & "圆的周长" & L) End Sub Private Sub Command2_Click() R = InputBox("请输入圆的半径") S = 3.1415926 * (R ^ 2) L = 2 * 3.1415926 * R MsgBox ("圆的面积" & S & vbCrLf & "圆的周长" & L) End Sub

就两个公式嘛圆的周长=2*半径*圆周率=直径*圆周率 即:圆的周长=2πr 或πD面积:s=πr 或s=π(d/2)程序,自己弄一个textbox 1用来e5a48de588b63231313335323631343130323136353331333332633633输入圆的半径 textbox2用来显示计

Private Sub Command1_Click()Dim r As Doubler = InputBox("请输入半径:", "输入半径")Print "圆的面积是: (r ^ 2 * 3.14159)"End Sub 在窗体上建立一个按扭然后双击进去,输入上面的代码就可以了!

网站首页 | 网站地图
All rights reserved Powered by www.sppk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com