Yeah, I've never used ReDim Preserve but as I understand the documentation that won't work in this case.
The simplest way may indeed be to read the file twice. It probably wouldn't slow your program down, much.
A more complicated alternative, if you want to try it, would be to have two arrays, and every time you have to "delete" the first 20K-or-whatever entries you just ReDim the other array and copy over the last 5K lines. Since that involves all RAM, not disc I/O, it might be faster. Might be a pain to program reliably, though; I'd probably just read the file twice, unless it's so big that reading it twice slows your program down by 15% or more.
But there's another possibility; how about using a Collection? That makes it much easier, because you can delete the first item, or indeed any item at all, from a Collection. It may be slower but it may not; I've had to store a lot of information in collections, from time to time, and I can't tell that they're any slower than arrays.
|