我认为第二个问题是由于c#和vba之间的差异,但是我不确定100%是否会得到任何帮助。
从根本上说
kraj = False
j = 0
While kraj = False
For i = 0 To 6 Step 1
Cells(1, "A") = output(i, stacks(i))
j = j + 1
Next i
For i = 0 To 6 Step 1
stacks(i) = stacks(i) + 1
If (stacks(i) = 3) Then
If (i = 0) Then
kraj = True
Else
stacks(i) = 0
End If
Else
End If
Next i
Wend
这是C#中的有效代码
int[] ics = new int[7];
bool end = false;
int number_of_lines = 0;
while (!end)
{
for (int i = 0; i < 7; i++)
{
Console.Write(output[i][ics[i]]);
if (i / 6 == 1)
{
Console.WriteLine(); number_of_lines++;
}
}
for (int i = ics.Length - 1; i >= 0; i--)
{
ics[i]++;
if (ics[i] == output[i].Length)
if (i == 0)
end = true;
else
ics[i] = 0;
else
break;
}
}
答案 0 :(得分:0)
此示例演示了基于1的数组的使用,该数组可以一次性粘贴(放置)到一个范围中(请参阅最后一行代码)。
Sub ArrayExample()
Const cLngRow As Long = 7 ' Array Number of Rows
Const cIntColumn As Integer = 3 ' Array Number of Columns
Const cStrFirst As String = "A1" ' Target First Cell Range
Dim vntEx As Variant ' Array
Dim i As Long ' Array Row Counter
Dim j As Integer ' Array Column Counter
' Resize Array
ReDim vntEx(1 To cLngRow, 1 To cIntColumn)
' Write to array.
For i = 1 To cLngRow
For j = 1 To cIntColumn
vntEx(i, j) = i * j
Next
Next
' Print array to Immediate window
For i = 1 To cLngRow
For j = 1 To cIntColumn
Debug.Print vntEx(i, j)
Next
Next
' Paste array into Worksheet. You don't have to loop.
Range(cStrFirst).Resize(UBound(vntEx, 1), UBound(vntEx, 2)) = vntEx
End Sub