0

I believe the problem is in the second for because of the differences between c# and vba but I'm not 100% sure so any and all help would be appreciated.

Literally everything

    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

This is working code in 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;
    }
}
Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • Hi, please take a moment to read [this](https://stackoverflow.com/help/how-to-ask). Your question should include a clear problem statement, the output you expect, the output you receive, the difference between the two, where you are stuck, and what you have done to try to resolve the problem. – anothermh Dec 30 '18 at 22:53
  • Did you look at [this answer](https://stackoverflow.com/q/29078363/4717755) – PeterT Dec 30 '18 at 22:54
  • i tried correcting it – Zoran Vidovic Dec 30 '18 at 23:00
  • You should explain what you are trying to do? What are output and stacks? One guess could be that you are trying to write data from an array to a range on a worksheet. You should edit your question and put this information inside it. Showing part of the desired result might also help. – VBasic2008 Dec 30 '18 at 23:44
  • Hi, you need to show how all variables and arrays are declared and filled. – Patrick Lepelletier Jan 01 '19 at 20:00

1 Answers1

0

Array Example

This example demonstrates the use of 1-based arrays which can be pasted (deposited) into a range in one go (see last line of code).

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
VBasic2008
  • 44,888
  • 5
  • 17
  • 28