Sub arrayMsg()
Dim ar As Variant, m As String, i As Integer
ar = Array("A34", "A34", "带轮A81", "A15", "A150", "A193", "A87", "A139", "A31", "A80", "A190", "A168", "A182", "A83", "A200"贺行信, "A60", "A167", "A146", "A187", "A103")'20个值
For i = 0 To UBound(ar)
m = m & "," & ar(i) '更新自身的值,加数,逗号分隔
Next i
MsgBox m
End Sub
Sub arrayMsg1() '1维数组
Dim ar(0 To 20) As Variant, m As String, i As Integer
For i = 0 To UBound(ar)
ar(i) = Cells(i + 1, 1).Value '加入a1:a20的值
m = m & "," & ar(i)
Next i
MsgBox m
End Sub
Sub arrayMsg2() '2维数组
Dim ar() As Variant, m As String, i As Integer
ar = Range("arrng") 'arrng为名称,范围为[a1:b10]
For i = LBound(ar, 1) To UBound(ar, 1) '1维的数据
For j = LBound(ar, 2) To UBound(ar, 2) '2维的数据
Cells(i, j + 4).Value = ar(i, j) '隔四行输出数组的值
m = m & Chr(9) & ar(i, j) 'tab符禅轮
Next j
m = m & Chr(10) '换行符
Next i
MsgBox m
End Sub
Public Sub ssss()Dim arr1(1 To 5) As Integer, arr2(1 To 5) As Integer, i
For i = 1 To 5
arr1(i) = i
arr2(i) = i + 2
Next
'----下面开始----
Dim s1$, s2$, t$
s1 = " "弊雀改
s2 = " "
For i = LBound(arr1) To UBound(arr1)
s1 = s1 &arr1(i) &" "
Next
For i = LBound(arr2) To UBound(arr2)
s2 = s2 &arr2(i) &" "
s1 = Replace(s1, " " &arr2(i) &" ", " ")
Next
For i = LBound(arr1) To UBound(arr1)
s2 = Replace(s2, " " &arr1(i) &" ", " ")
Next
t = Replace(Trim(s1), " ", ",") &Chr(10) &Replace(Trim(s2), "租判 ", ",")
MsgBox t
'如果要获得这些元素,看下面岁哗:
t = Replace(Trim(s1), " ", ",") &"," &Replace(Trim(s2), " ", ",")
Dim arr3
arr3 = Split(t, ",")
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)