I have an array with 2275 items in it. Each is a string consisting of 5 items delimited by the "#" symbol, for example:
com1#0582#03/29/05 2:11:44 AM#1#0
com9#0522#03/31/05 2:29:25 AM#0#1
com 103#0596#03/02/05 12:45:54 AM#157270#59529
com6#0502#03/16/05 3:38:52 AM#2#1
com7#0500#03/14/05 2:48:22 AM#406#3207
comp2#0522#03/07/05 4:45:34 AM#81#290
com 103#0552#03/25/05 12:44:58 AM#2647#1050
com7#0500#03/14/05 12:49:52 PM#406#3207
the first part of each is a company number. This is not a fixed length, unfortunately. The second is a subcompany, always 4 digits. The third part of this is a date and time for a billing cycle, and is the focus of my loop. Out of the 2275 items in the loop, about 60 (this month, at least) need to be deleted. For an example, look at the two 'com7' lines above. Both have a cycle date of 03/14/05, but the first was earlier in the day. In cases like this where the first two fields are the same, and the day is the same, I need to delete the earlier of the dates (the times will never be the same). I'm using a loop to look through them all, and when the time is earlier I just clear out that item in the array. Afterwards I go through and transfer the non-blank entries to another array. The transfering of the non-blanks is very quick, takes about a second, but the loop to go through the actual entries takes about 32 seconds. I'm hoping I can bring that down a bit with all of your help!
Here is the code I'm using to look through the items, in array named "u":
for i = lbound(u) to ubound(u)
if u(i)<>"" then
for j = i + 1 to ubound(u)
if u(j)<>"" then
if a(0)=b(0) then
if a(1)=b(1) then
if day(a(2))=day(b(2)) then
if a(2)>b(2) then u(j)="" else u(i)=""
This looks sloppy to me, but I can't figure out a better way to do this. Can this be improved?