07-06-2025, 02:42 PM
Sorry Steve, I haven't been able to re-create the error solution by removing the underscore in the Array name. Here is the code that I have been playing with, well almost the code, the only difference is the Read Data approach as my actual code is opening a the file with the approx 4500 lines of data.
Originally when I wrote my hallelujah comment above the first instance of dataarray() was accepted but had an out of range error on the total_lines, which I hadn't changed to "totallines" so it appeared the run was no longer erroring out on dataarray().
Anyway, here's the code snippet where I'm getting an Out of Range error on data_array()
Originally when I wrote my hallelujah comment above the first instance of dataarray() was accepted but had an out of range error on the total_lines, which I hadn't changed to "totallines" so it appeared the run was no longer erroring out on dataarray().
Anyway, here's the code snippet where I'm getting an Out of Range error on data_array()
Code: (Select All)
Dim Shared data_array(1 To 100, 1 To total_lines)
'Dim Shared dataarray(1 To 100, 1 To totallines)
Dim Shared Repeat(1 To 100, 1 To total_lines)
Dim Shared LinesTotal
Dim Shared Num
Do While Num <> 101
Read Num
numcount = numcount + 1
If numcount = 10 Then
LinesTotal = LinesTotal + 1
numcount = 0
End If
Loop
total_lines = LinesTotal
Restore
For i = 1 To total_lines
For j = 1 To 10
If Num(j) = 101 Then Exit For
Read Num(j)
data_array(Num(j), i) = _TRUE
'dataarray(Num(j), i) = _TRUE
Next j
Next i
Restore
For i = 1 To total_lines
For k = 1 To 100 'to check the 100 numbers
If dataarray(i, k) = _FALSE Then _Continue 'no need to check the next 7 values as this number doesn't exist on this line
For j = i + 1 To i + 7 'to check the next 7 lines
If j > total_lines Then Exit For 'you're above the data limit. Skip checking.
If data_array(j, k) = _TRUE Then 'it's a match, do whatever you want with this match. The value is k, it's on both lines i and j
Repeat(i, k) = Repeat(i, k) + 1
End If
Next j
Next k
Next i
For TL = 1 To total_lines
Print Repeat(TL, 14);
Next TL
Data 1,15,31,25,82,12,63,64,50,47
Data 66,22,18,93,84,88,98,10,6,27
Data 19,45,46,11,12,57,71,93,100,3
Data 24,33,96,56,17,5,87,4,5,99
Data 94,17,77,89,20,76,90,8,40,49
Data 6,43,53,14,11,80,92,100,9,3
Data 84,77,73,57,28,8,15,65,69,2
Data 70,29,21,100,71,36,44,16,97,69
Data 19,83,88,23,97,80,28,5,83,84
Data 100,4,39,35,86,12,13,68,64,74
Data 101
