vb.net中数组的函数 vb使用数组

vb.net 编写一个函数注意:参数为动态数组;
Private Function MyF(ByRef d() As Integer)
ReDim d(4, 13) As Integer
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim MyNum(4) As Integer
For i = 1 To 4
MyNum(i) = 0
Next i
Randomize
For i = 1 To 4
For j = 1 To 13
n = Int(Rnd * 4 + 1)
Do While MyNum(n) = 13
n = Int(Rnd * 4 + 1)
Loop
d(i, j) = n
MyNum(n) = MyNum(n) + 1
Next j
Next i
End Function
VB.net 如何编写一个可以返回数组的函数(过程)?public function createstringarr() as string()
return new string(){"d1","d2","d3","d4"}
end function
vb.net中返回一个数组的函数的问题给你一个简单的示例:
Option Explicit
Private Function GetRndInt() As Integer()
' 返回一个 Integer类型的数组
Dim i As Long, aTemp() As Integer
Randomize
ReDim aTemp(15)
For i = 0 To 15
aTemp(i) = Rnd() * 500
Next
GetRndInt = aTemp
End Function
Private Sub Command1_Click()
Dim aTemp() As Integer
Dim i As Long
Me.Cls
aTemp = GetRndInt
Print "随机产生的数据为:"
For i = 0 To UBound(aTemp)
Print i + 1, aTemp(i)
Next
【vb.net中数组的函数 vb使用数组】End Sub
运行效果:
vb.net 返回一个数组的函数public function createstringarr() as string()
return new string(){"d1","d2","d3","d4"}
end function
vb.net中数组的函数的介绍就聊到这里吧 , 感谢你花时间阅读本站内容 , 更多关于vb使用数组、vb.net中数组的函数的信息别忘了在本站进行查找喔 。

    推荐阅读