发布网友 发布时间:2022-04-25 00:03
共3个回答
热心网友 时间:2023-10-16 13:46
Private Sub Form_Click()
dim aa
aa=0
Dim arr1(10) As Integer, k As Integer, s As Integer
For k = 0 To 10
arr1(k) = Int(Rnd * 900 + 100)
aa=aa+arr1(k)
Next k
Print "数组元素之和为:" + aa
End Sub
如果要在外面来调用,为什么不用函数而用过程呢
Print "数组元素之和为:" + hihi(arr1)
Private function hihi(a)
dim k,b
b=0
for k=0 to 10
b=b+a[k]
next k
hihi=b
end function
热心网友 时间:2023-10-16 13:46
Private Sub Form_Click()
Dim arr1(10) As Integer, k As Integer, s As Integer
For k = 0 To 10
arr1(k) = Int(Rnd * 900 + 100)
Next k
Call abc(arr1, s)
Print "数组元素之和为:" + CStr(s)
End Sub
Private Sub abc(arr2, ByRef ss)
For j = 0 To 10
ss = ss + arr2(j)
Next j
End Sub
热心网友 时间:2023-10-16 13:47
Private Sub Form_Click()
Dim arr1(10) As Integer, k As Integer, s As Integer
For k = 0 To 10
arr1(k) = Int(Rnd * 900 + 100)
Next k
Call hihi(arr1(), s)
Print "数组元素之和为:" + CStr(s)
End Sub
Private Sub hihi(arr2() As Integer, ss As Integer)
For j = 0 To 10
ss = ss + arr2(j)
Next j
End Sub