以下の2次元配列があります。
Dim ForExample1(,) As String = {{"1","1","平野"}, _
{"2","1","小川"}, _
{"3","1","ブライアント"}, _
{"4","1","オグリビ"}} _
Dim ForExample2(,) As String = {{"1","2","大石"}, _
{"2","2","新井"}, _
{"4","2","中村"}} _
Dim ForExample3(,) As String = {{"2","3","水口"}}
以上3つの2次元配列を下記のように統合したいのです。
Dim ForExampleAll(,) As String = {{"1","1","平野"}, _
{"2","1","小川"}, _
{"3","1","ブライアント"}, _
{"4","1","オグリビ"}, _
{"1","2","大石"}, _
{"2","2","新井"}, _
{"4","2","中村"}, _
{"2","3","水口"}} _
やはりfor nextでの処理しかできないのでしょうか
面白そうだったので無理やりやってみました。
↓参考にもならないかもれしれませんが、For Next以外の1例だと思ってください。
Dim ForExample1(,) As String _
= {{"1", "1", "平野"}, _
{"2", "1", "小川"}, _
{"3", "1", "ブライアント"}, _
{"4", "1", "オグリビ"}}
Dim ForExample2(,) As String _
= {{"1", "2", "大石"}, _
{"2", "2", "新井"}, _
{"4", "2", "中村"}}
Dim ForExample3(,) As String _
= {{"2", "3", "水口"}}
Dim ForExampleAll(,) As String
Dim For1Len, For2Len, For3Len, ForAll0Index As Integer
For1Len = ForExample1.Length
For2Len = ForExample2.Length
For3Len = ForExample3.Length
ForAll0Index = ForExample1.GetUpperBound(0) + ForExample2.GetUpperBound(0) + ForExample3.GetUpperBound(0) + 2
ReDim ForExampleAll(ForAll0Index, 2)
Array.Copy(DirectCast(ForExample1, Array), 0, _
DirectCast(ForExampleAll, Array), 0, _
For1Len)
Array.Copy(DirectCast(ForExample2, Array), 0, _
DirectCast(ForExampleAll, Array), For1Len, _
For2Len)
Array.Copy(DirectCast(ForExample3, Array), 0, _
DirectCast(ForExampleAll, Array), For1Len + For2Len, _
For3Len)
ツイート | ![]() |