So I had to make a 2D array that would append the percentage of change from the previous row to the current row at the end of that row. For example:


50 100 100 50 0.00 0.00 0.00 0.00
50 200 50 25 0.00 100 -50 -50

Now I have this part down but now i need to make it so it creates another row at then end that says the percentage change overall.


here is the code I have so far
Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim col As Integer

        Dim rows() As String = IO.File.ReadAllLines("C:\sales.txt")

        Dim All(rows.GetUpperBound(0), rows(0).Split(New String() {Chr(9)}, StringSplitOptions.RemoveEmptyEntries).GetUpperBound(0)) As Decimal

        Dim newRows As New List(Of String)

        For row As Integer = 0 To rows.GetUpperBound(0)

            Dim parts() As String = rows(row).Split(New String() {Chr(9)}, StringSplitOptions.RemoveEmptyEntries)

            newRows.Add(String.Join("   ", parts) & "   ")

            For column As Integer = 0 To parts.GetUpperBound(0)
                col = parts.GetUpperBound(0)
                All(row, column) = CDec(parts(column))

                If row > 0 Then

                    newRows(newRows.Count - 1) &= (((All(row, column) / All(row - 1, column)) * 100) - 100).ToString("n2") & "  "
               
                ElseIf row = 0 AndAlso column = 0 Then

                    Dim d(parts.GetUpperBound(0)) As Decimal

                    newRows(newRows.Count - 1) &= String.Join(" ", Array.ConvertAll(Of Decimal, String)(d, Function(v As Decimal) v.ToString("n2")))

                End If

            Next

        Next

        TextBox1.Lines = newRows.ToArray




        'to save:

        IO.File.WriteAllLines("C:\Solution.txt", newRows.ToArray)

        ' squareArray is the array
        MessageBox.Show("Done!!!")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()

    End Sub
End Class