【vb数组】VB数组问题如下数组声明语句则数组a包含元素的个数....
答案:2 悬赏:0 手机版
解决时间 2021-01-25 05:59
- 提问者网友:我们很暧昧
- 2021-01-24 14:38
【vb数组】VB数组问题如下数组声明语句则数组a包含元素的个数....
最佳答案
- 五星知识达人网友:西风乍起
- 2021-01-24 15:59
【答案】 窗体上建立两个按钮,两个文本框
Private Sub Command1_Click()
Dim i As Integer, s As Integer, aver As Single
Dim myarray(1 To 10)
For i = 1 To 10
myarray(i) = i '数组赋值
s = s + myarray(i) '求和
Next i
aver = s / 10 '求平均值
Text1.Text = aver
End Sub
Private Sub Command2_Click()
Dim i As Integer, s As Integer, aver As Single, x As Integer
Dim DYarray() As Integer
x = InputBox(请输入一个值,它是元素个数, 元素个数)
ReDim DYarray(1 To x)
For i = 1 To x
DYarray(i) = InputBox(请输入第 & i & 个元素, 输入每个元素) '数组赋值
s = s + DYarray(i) '求和
aver = s / x '求平均值
Next i
Text2.Text = aver
End Sub
Private Sub Command1_Click()
Dim i As Integer, s As Integer, aver As Single
Dim myarray(1 To 10)
For i = 1 To 10
myarray(i) = i '数组赋值
s = s + myarray(i) '求和
Next i
aver = s / 10 '求平均值
Text1.Text = aver
End Sub
Private Sub Command2_Click()
Dim i As Integer, s As Integer, aver As Single, x As Integer
Dim DYarray() As Integer
x = InputBox(请输入一个值,它是元素个数, 元素个数)
ReDim DYarray(1 To x)
For i = 1 To x
DYarray(i) = InputBox(请输入第 & i & 个元素, 输入每个元素) '数组赋值
s = s + DYarray(i) '求和
aver = s / x '求平均值
Next i
Text2.Text = aver
End Sub
全部回答
- 1楼网友:woshuo
- 2021-01-24 16:47
感谢回答
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯