I have a simple array of integer numbers (15 characters in length) which can hold up to 2000 items. What I basically need to do is output these numbers to a PDF file I'm creating on the fly and I can only fit a certain amount of numbers per page. What I need to do is just output these on each page in numerical order vertically NOT horizontally. Based on page size restrictions, the amount of numbers I can output per page is 19 rows x 7 columns (or 133 items total).
Now, I already have the PDF creation going fine, including adding more pages as there's more numbers being added, etc. It's just the sorting of these numbers that I'm outputting I'm having trouble with. What I'm doing currently (which is archaic), since I can only output horizontally at the moment, is outputting the first number, then skipping the next 18, and then outputting the next number, then skipping the next 18, etc. Once I get to the 7th number (1st row, 7th column), I output it, skip backwards to the 2nd number in the array, and output it as I'll now be in the 2nd row (2nd row, 1st column). I keep doing this until all numbers in the array are output. The only problem is that, other than being finicky and definitely not an efficient way of doing it, is if the array has fewer than 133 numbers (or if by chance there's fewer than 133 numbers on any one page), the output structure is all messed up.
For more info on what I'm currently doing, here's some code examples:
Expand|Select|Wrap|Line Numbers
- Dim theTagArray(2000) As String
- ' theTagArray is filled before this next section...
- Dim thecount2 As Integer = 0
- Dim thecount3 As Integer = 0
- Dim thenum As Integer = 19
- ' Nice mess to print tags in numeric order down each column, left to right...
- ' Basically, start with first element, then skip 18 and put next, skip 18 put next, etc. and so forth...
- ' pdfText2a.Add is the function that's basically outputting the array element... to the PDF...
- If thecount3 = 7 Then
- thecount2 += 1
- thecount3 = 0
- pdfText2a.Add(theTagArray(thecount2 + (thecount3 * thenum)) & " | ")
- thecount3 += 1
- Else
- pdfText2a.Add(theTagArray(thecount2 + (thecount3 * thenum)) & " | ")
- thecount3 += 1
- End If
982000018301450 | 982000018561709 | ...Though 7 across, 19 down.
982000018561265 | 982000018561724 | ...
...
So, this is why I'm asking if there's a way to output an array vertically instead of horizontally in either a slightly more efficient way than I'm doing it, or by using a much better method altogether. Please help if you can. Thanks for your help.