s = Val(InputBox("输入底面积"))
h = Val(InputBox("高"))
r = Val(InputBox("地面半径"))
V = 1 / 3 * s * h ' S是底面积,h是高,r是底面半径
Print "圆锥的体积为"V
End Sub
Private Sub Command2_Click()
pi = 3.1415926
r = Val(InputBox("半径"))
V = (4 / 3) * pi * r ^ 3
Print "球体的体积为"V
End Sub
Private Sub Command3_Click()
pi = 3.1415926
r = Val(InputBox("底面锋岁半径"))
h = Val(InputBox("高"))
V = 2 * pi * r * h
Print "圆柱型基闷的体积"V
End Sub
Private Sub Command4_Click()
a = Val(InputBox("卜弯边长"))
V = a * a * a
Print "正方体的体积"V
End Sub
按功能键盘上的F5 运行就可以! 如果有错误,VB会出现新窗口闹罩孙,用汉字写出如何错误。在新窗口内点击调试,在代码窗口中出错的代码为黄色背景。 最后保存程序,单击液链“文件”菜单——选择“保存工程”。需要保存两个窗体,首先是.frm的应用程序窗体,然后是.vbp的闷早工程文件。楼主您好!
代码如下:
Option ExplicitPrivate Sub Command1_Click()
Dim n(7) As Double
Dim k(3) As Double
k(3) = 1
Dim j As Integer
For j = 1 To 7
n(j) = Val(Controls("Text" & CStr(j)).Text)
Next j
For j = 1 To 7
k(1) = k(1) + n(j)
李祥k(2) = k(2) - n(j)
k(3) = k(3) * n(j)
Next j
Me.Text8.Text = "7个数的和为:" & k(1) & vbCrLf & _
"7个数的差为:" & k(2) & vbCrLf & _
"7个数的乘积为:" & k(3)
End Sub
Private Sub Command2_Click()
哪埋搏 Dim i As Integer
For 液手i = 1 To 8
Controls("Text" & CStr(i)).Text = ""
Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 8
Controls("Text" & CStr(i)).Text = ""
Next i
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)