vb中function参数列表中二维数组作为形参怎么用
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
与一维数组用法一样,以下是个例子:
Private Sub Command1_Click()
Dim a(2, 2) As Integer
Dim i As Integer, j As Integer, m As Integer
For i = 0 To 2
For j = 0 To 2
m = m + 1
a(i, j) = m
Next
Next
Debug.Print getValue(a)
End Sub
Private Function getValue(a() As Integer) As Integer
Dim s As Integer
Dim i As Integer, j As Integer
For i = LBound(a, 1) To UBound(a, 1)
For j = LBound(a, 2) To UBound(a, 2)
s = s + a(i, j)
Next
Next
getValue = s
End Function
Private Sub Command1_Click()
Dim a(2, 2) As Integer
Dim i As Integer, j As Integer, m As Integer
For i = 0 To 2
For j = 0 To 2
m = m + 1
a(i, j) = m
Next
Next
Debug.Print getValue(a)
End Sub
Private Function getValue(a() As Integer) As Integer
Dim s As Integer
Dim i As Integer, j As Integer
For i = LBound(a, 1) To UBound(a, 1)
For j = LBound(a, 2) To UBound(a, 2)
s = s + a(i, j)
Next
Next
getValue = s
End Function
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询