一道题 急需编一个VB小程序
从键盘上出入4个数,编写程序,计算并输出着四个数的和及平均数。通过InputBox函数输入数据。比在窗体上显示和及平均值谢拉...
从键盘上出入4个数,编写程序,计算并输出着四个数的和及平均数。通过InputBox函数输入数据。比在窗体上显示和及平均值 谢拉
展开
6个回答
展开全部
Private Sub Form_Load()
Dim a(3), sum
For i = 0 To 3
a(i) = InputBox("输入第" & i + 1 & "¸数字")
sum = sum + a(i)
Next
MsgBox "和为:" & sum & ",平均数为:" & sum / 4
End Sub
Dim a(3), sum
For i = 0 To 3
a(i) = InputBox("输入第" & i + 1 & "¸数字")
sum = sum + a(i)
Next
MsgBox "和为:" & sum & ",平均数为:" & sum / 4
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a, b, c, d, e
a = InputBox("a")
b = InputBox("b")
c = InputBox("c")
d = InputBox("d")
e = (CInt(a) + CInt(b) + CInt(c) + CInt(d)) / 4
Print "第一个数=" & a, "第二个数=" & b, "第三个数=" & c, "第四个数=" & d, "和=" & e
End Sub
Dim a, b, c, d, e
a = InputBox("a")
b = InputBox("b")
c = InputBox("c")
d = InputBox("d")
e = (CInt(a) + CInt(b) + CInt(c) + CInt(d)) / 4
Print "第一个数=" & a, "第二个数=" & b, "第三个数=" & c, "第四个数=" & d, "和=" & e
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
Dim a(4) As Integer
Dim Sum As Integer, PJ As Single
For I = 1 To 4
a(I) = InputBox("请输入数字:", "输入")
Sum = Sum + a(I)
Print Sum
Next I
PJ = Sum / 4
Print PJ
End Sub
Dim a(4) As Integer
Dim Sum As Integer, PJ As Single
For I = 1 To 4
a(I) = InputBox("请输入数字:", "输入")
Sum = Sum + a(I)
Print Sum
Next I
PJ = Sum / 4
Print PJ
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim s, a As Double
s = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text)
a = s / 4
Print s
Print a
End Sub
Dim s, a As Double
s = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text)
a = s / 4
Print s
Print a
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim s1 As Double
Dim s As Double
s = 0
For i = 0 To 3
s1 = InputBox("请输入数字")
s = s + s1
Next
Print s
Print s / 4
Dim s As Double
s = 0
For i = 0 To 3
s1 = InputBox("请输入数字")
s = s + s1
Next
Print s
Print s / 4
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询