vb 数组操作

引用:http://hi.baidu.com/yongjianspaces/blog/item/3f10ae9980ce5e1d6f068c7d.html

 

Public FunctionTest(a() As Byte, b() As ByteAs Variant
Dim i As Integer
Dim c() As Integer
ReDim c(UBound(a, 1), UBound(b, 1))  
For i = 0 To UBound(a, 1)
’代码自行添加
Next i
Test 
= c
End Function

Public Function iMUL(a() As Integer, b() As IntegerAs Variant
Dim i, j, k As Integer
If UBound(a, 2) <> UBound(b, 1Then
MsgBox "参数错误,请输入两个可以相乘的矩阵!"
End
End If
Dim c() As Integer
ReDim c(UBound(a, 1), UBound(b, 2))
For i = 0 To UBound(a, 1)
  For k = 0 To UBound(b, 2)
       c(i, k) = 0
    For j = 0 To UBound(a, 2)
       c(i, k) = c(i, k) + a(i, j) * b(j, k)
    Next j
  Next k
Next i
iMUL = c
End Function
posted @ 2011-11-10 10:16  镇水古月  阅读(322)  评论(0编辑  收藏  举报