如何把结构一样的两个数组合并成一个数组
如题
谢谢!!!!
[解决办法]
vbs的数组操作比较麻烦。比个方法你吧
dim arr1=[1,2,3]
dim arr2=[4,5,6]
dim arr(length(arr1)+length(arr2)-1)//新数组的长度为两个数组长度的和。
dim i=0
for i,i<length(arr1)-1,i++
arr[i]=arr1[i]
end for
dim j=length(arr1)-1
dim k=0
for j,j<length(arr),j++
arr[j]=arr2[k]
end for
上面的是方法,至于vbs的函数,我不记得,可能是错的。
[解决办法]
msgbox split(join(arr1,",") & "," join(arr2,","),",")
如果是字符串数组,若其中包含逗号,则可能出错。
可以直接redim 来实现,例如:
i = UBound(arr1) + 1ReDim Preserve arr1(i + UBound(arr2) + 1)For j = 0 To UBound(arr2) arr1(j+i) = arr2(j)NextWScript.Echo Join(arr1,",")
[解决办法]
dim combinedArray()combinedArray = split(join(array1,"|") & "|" & join(array2,"|") ,"|")
[解决办法]