还是有点麻烦,我是这样的
Function CreateArray(TypeName As VbVarType, ParamArray ValArray()) Dim i, mArray Dim nCount As Integer
nCount = UBound(ValArray)
Select Case TypeName Case vbDouble Dim dArray() As Double ReDim dArray(nCount) mArray = dArray Case vbInteger Dim nArray() As Integer ReDim nArray(nCount) mArray = nArray Case vbString Dim sArray() As String ReDim sArray(nCount) mArray = sArray Case vbVariant Dim vArray() ReDim vArray(nCount) mArray = vArray End Select
For i = 0 To nCount mArray(i) = ValArray(i) Next i