![]() |
Breaking up an array into parts
I have an array of strings that is fed into an external function in a
COM. I've found that the code inside has a "break point" where too many strings suddenly makes it run much slower (memory problem?). If you call the code with batches of strings it runs much faster. So how do I do this? I have a "securities(0 to records -1)", and I want to break that down into chunks of no more than 50 at a time. The last array cannot have any empty cells at the end. I thought of using a comma-delimited string of everything in "securities" and then using Split, but that would always return the first 50 strings, without some string manipulation anyway. Maury |
Breaking up an array into parts
Maury Markowitz wrote:
I have an array of strings that is fed into an external function in a COM. I've found that the code inside has a "break point" where too many strings suddenly makes it run much slower (memory problem?). If you call the code with batches of strings it runs much faster. So how do I do this? I have a "securities(0 to records -1)", and I want to break that down into chunks of no more than 50 at a time. The last array cannot have any empty cells at the end. I thought of using a comma-delimited string of everything in "securities" and then using Split, but that would always return the first 50 strings, without some string manipulation anyway. Hi Maury, Set up a couple loops to control the paging. Here's a rough sketch: 'Outer loop For j = 0 to arraysize\50 PageOffset = j * 50 'Inner loop For k = 0 to 49 TargetIndex = PageOffset + k ' check to make sure TargetIndex is not past the end of the array ' if ok, add item MyArray(TargetIndex) to the batch Next k 'Now the batch is built. Call the COM Next j |
Breaking up an array into parts
So, what is the problem then with passing the first 50 array elements, then
the second 50 array elements etc., adjusting for the last lot of elements? You could pass them in a 50 element array, again adjusting for the last bit. RBS "Maury Markowitz" wrote in message ... I have an array of strings that is fed into an external function in a COM. I've found that the code inside has a "break point" where too many strings suddenly makes it run much slower (memory problem?). If you call the code with batches of strings it runs much faster. So how do I do this? I have a "securities(0 to records -1)", and I want to break that down into chunks of no more than 50 at a time. The last array cannot have any empty cells at the end. I thought of using a comma-delimited string of everything in "securities" and then using Split, but that would always return the first 50 strings, without some string manipulation anyway. Maury |
All times are GMT +1. The time now is 07:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com