あなたがループの場合、ネストされたと
注これを達成することができる:配列の要素を反復処理するために、各ループについて使用する場合、各反復で生成されたプレースホルダは、実際の配列内の値のコピーです。その値の変更は元の配列に反映されません。情報を読む以外のことをしたい場合は、配列要素を直接扱うためにForループを使う必要があります。
2次元配列を仮定すると、次のコード例は各次元の各要素に値を割り当てます。
Dim MasterIndex(5, 2) As String
For iOuter As Integer = MasterIndex.GetLowerBound(0) To MasterIndex.GetUpperBound(0)
'iOuter represents the first dimension
For iInner As Integer = MasterIndex.GetLowerBound(1) To MasterIndex.GetUpperBound(1)
'iInner represents the second dimension
MasterIndex(iOuter, iInner) = "This Isn't Nothing" 'Set the value
Next 'iInner
'If you are only interested in the first element you don't need the inner loop
MasterIndex(iOuter, 0) = "This is the first element in the second dimension"
Next 'iOuter
'MasterIndex is now filled completely
オプションで、コンラートルドルフのようなギザギザの配列が示唆された上で、あなたがループする場合(これは機能的に、より密接に、より緩く他に、アレイの実装と一致する動的
各次元上を反復する
.Rank
プロパティを使用することができますPHPのような型付き言語で)あなたはそうのようにそれについて行くことができます:
'This is a jagged array (array of arrays) populated with three arrays each with three elements
Dim JaggedIndex()() As String = {
New String() {"1", "2", "3"},
New String() {"1", "2", "3"},
New String() {"1", "2", "3"}
}
For Each aOuter As String() In JaggedIndex
'If you are only interested in the first element you don't need the inner for each loop
Dim sDesiredValue As String = aOuter(0) 'This is the first element in the inner array (second dimension)
For Each sElement As String In aOuter
Dim sCatch As String = sElement 'Assign the value of each element in the inner array to sCatch
sElement = "This Won't Stick" 'This will only hold value within the context of this loop iteration
Next 'sElement
Next 'aOuter
'JaggedIndex is still the same as when it was declared
は、私はあなたのより詳細な要求 – JoshHetland