VB中数组赋值问题:我有两个数组A=(1,2,3);B=(4,5,6)现在怎么样让A数组值变为A=(1,2,3,4,5,6) ??
我有两个数组A=(1,2,3);B=(4,5,6)现在怎么样让A数组值变为A=(1,2,3,4,5,6),以上只是举例,第一数组A里面的元素个数不确定,B里面也不确定,第...
我有两个数组A=(1,2,3);B=(4,5,6)现在怎么样让A数组值变为A=(1,2,3,4,5,6),以上只是举例,第一数组A里面的元素个数不确定,B里面也不确定,第二A里面可能没有数据。请问能否实现把B的值赋到A里面,并且在A有值的情况下是接在A现存值后面的
展开
2个回答
展开全部
Dim A() As Integer
Dim B() As Integer
Dim LA As Long
Dim LB As Long
Dim i%
ReDim A(2)
ReDim B(2)
'给A,B赋值
A(0) = 1
A(1) = 2
A(2) = 3
B(0) = 4
B(1) = 5
B(2) = 6
'赋值结束
LA = UBound(A) - LBound(A) + 1
LB = UBound(B) - LBound(B) + 1
ReDim Preserve A(LA + LB - 1)
For i = LA To LA + LB - 1
A(i) = B(i - LA)
Next
Dim B() As Integer
Dim LA As Long
Dim LB As Long
Dim i%
ReDim A(2)
ReDim B(2)
'给A,B赋值
A(0) = 1
A(1) = 2
A(2) = 3
B(0) = 4
B(1) = 5
B(2) = 6
'赋值结束
LA = UBound(A) - LBound(A) + 1
LB = UBound(B) - LBound(B) + 1
ReDim Preserve A(LA + LB - 1)
For i = LA To LA + LB - 1
A(i) = B(i - LA)
Next
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询