I have the following code:
It is meant to put the contents of memOrig into memNew in a random order. For some reason that I can't see, there is are always some items left in memOrig (usually two, but not always). I tried changing the For statement to a fixed number (the number of items in it), with the same result. I've got to be missing something obvious as this is only a small, simple piece of code. Can anyone spot it?
Code:
Randomize;
For i := 1 to frmMain.memOrig.Lines.Count do
begin
RandNo := Random(frmMain.memOrig.Lines.Count)+1;
frmMain.memNew.Lines.Add(frmMain.memOrig.Lines[RandNo]);
frmMain.memOrig.Lines.Delete(RandNo);
end;
It is meant to put the contents of memOrig into memNew in a random order. For some reason that I can't see, there is are always some items left in memOrig (usually two, but not always). I tried changing the For statement to a fixed number (the number of items in it), with the same result. I've got to be missing something obvious as this is only a small, simple piece of code. Can anyone spot it?