I assume that your are quite new to VB.net but I may be wrong. I have therfore written the attached code using an array as you asked. I would not say it is the best method but if you are learning they I thought it better. Create a new project with a form1 and two listboxes (ListBox1 and ListBox2) Replace the code from your form with the attached code. It automatically generates test data to show you it working. It may not be exactly what you want but its a start.
Public Class Form1
Const NumberOfDaystocountBack = 4 'This is a constant for the number of dats you will count back
Dim OriginalDataArray(15, 5) As String 'This is a sample array with 15 records each with 5 pieces of data
Dim ResultsArray(1, 1) As String 'This is a sample array that will store the data, it is resized with the code
Private Sub Main()
'Generate test data
Dim X As Integer
Dim Y As Integer
Dim TempString As String
For X = 15 To 0 Step -1
TempString = ""
For Y = 0 To 4
OriginalDataArray(X, Y) = Int(Rnd() * 10)
TempString = TempString & OriginalDataArray(X, Y).ToString & ", "
Next
ListBox1.Items.Add(TempString)
Next
GenerateResults()
For X = 15 To 0 Step -1
TempString = ""
For Y = 0 To 3
TempString = TempString & ResultsArray(X, Y).ToString & ", "
Next
ListBox2.Items.Add(TempString)
Next
End Sub
Private Sub GenerateResults()
Dim MaxDayCount As Long
Dim LoopCounter As Integer
Dim RecordLoopCounter As Long
Dim DataLoopCounter As Long
Dim DataCount As Integer 'count of the number of data elements
Dim TempArray1() As Integer
Dim TempArray2() As Integer
DataCount = OriginalDataArray.GetUpperBound(1) 'This will be '5' for the sample array given
MaxDayCount = OriginalDataArray.GetUpperBound(0) 'This would be 50 for the sample array given
ReDim ResultsArray(MaxDayCount, NumberOfDaystocountBack) 'Resize the results array to accept data
For RecordLoopCounter = MaxDayCount To 0 Step -1 'Steps back through records of data
'Pass the two days data to the comparison function
For DataLoopCounter = 1 To NumberOfDaystocountBack
ReDim TempArray1(DataCount) 'Resize array to the number of data elements and clears data
ReDim TempArray2(DataCount) 'Resize array to the number of data elements and clears data
If RecordLoopCounter - DataLoopCounter >= 0 Then