Quote Originally Posted by szlamany
I actually think that the contents of the loop should be something that has nothing to do with A=A or I=J - something that's got more meat to it.
You bet. This is it:
VB Code:
  1. 'Loop #1
  2.     '*************************************************
  3.     For i = 0 To uLim
  4.         For n = 1 To 3
  5.             k = k + 1
  6.             Vector(k) = Gray(i)
  7.             If (k - GpL) Mod dummy = 0 Then
  8.                 For m = 1 To nb2a
  9.                     k = k + 1
  10.                     Vector(k) = 0
  11.                 Next
  12.             End If
  13.         Next
  14.     Next
  15.    
  16.     'Loop #2
  17.     '*************************************************
  18.     i = 0
  19.     Do
  20.         n = 1
  21.         Do
  22.             k = k + 1
  23.             Vector(k) = Gray(i)
  24.             If (k - GpL) Mod dummy = 0 Then
  25.                 m = 0
  26.                 Do While m < nb2a
  27.                     k = k + 1
  28.                     Vector(k) = 0
  29.                     m = m + 1
  30.                 Loop
  31.             End If
  32.             n = n + 1
  33.         Loop While n <= 3
  34.         i = i + 1
  35.     Loop While i <= uLim
I tested it for these values:
uLim = 58805
nb2a = 2
GpL = 726
dummy = 728
For loop #1 the time was 0.328 s. whereas loop #2 took 0.437 s.