The problem is in the second for cycle. T does not end. I can't figure out why it does? Can you tell me what my mistake is?
Set Jakobi = Rastr.Tables("jakobi")
Set yzel_i = Jakobi.Cols("ni")
Set yzel_j = Jakobi.Cols("nj")
Set dp_dv = Jakobi.Cols("b")
Dim array1(50, 2), j
j = 0
Dim array_r(50, 2)
k = 0
Dim t, m
For i = 0 To Jakobi.Size - 1
If yzel_i.Z(i) = yzel_j.Z(i) And yzel_i.Z(i) <> 0 Then
array1(j, 0) = yzel_i.Z(i)
array1(j, 1) = dp_dv.Z(i)
j = j + 1
End If
Next
k = 0
For i = 0 To Jakobi.Size - 1
If yzel_i.Z(i) <> yzel_j.Z(i) Then
t = 0
m = yzel_i.Z(i)
For Each x In array1
Rastr.Printp array1(t, 0)
If x <> m Then
array1(t, 2) = array1(t, 2) - dp_dv.Z(i)
End If
t = t + 1 '<------this place
Rastr.Printp t
Next
array_r(k, 1) = array1(t, 1) - dp_dv.Z(i)
array_r(k, 0) = yzel_i.Z(i)
k = k + 1
End If
Next
For i = 0 To UBound(array1)
Rastr.Printp array1(i, 0) & " " & array1(i, 2)
Next
'The answer looks like this: I only have 25 values, and it goes to the end of the array 51 1 52 2 4 3 3 4 1 5 2 6 152 7 151 8 15 9 7 10 71 11 6 12 72 13 8 14 13 15 9 16 12 17 101 18 102 19 11 20 10 21 14 22 141 23 142 24 5 25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
array1
is not a Collection so you cannot use For Each
to iterate through its values. You should simply use t
as the counter for a regular For...Next
loop:
For t = 0 To UBound(array1, 1) - 1
Rastr.Printp array1(t, 0)
If x <> m Then
array1(t, 2) = array1(t, 2) - dp_dv.Z(i)
End If
Rastr.Printp t
Next