468,769 Members | 2,302 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,769 developers. It's quick & easy.

VB-WEB: Array Output Sorting Issue

Hello. First of all I'm programming in VB.NET/ASP.NET doing a page for a website. Now, to my question....

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
  1. Dim theTagArray(2000) As String
  2. ' theTagArray is filled before this next section...
  3.  
  4. Dim thecount2 As Integer = 0
  5. Dim thecount3 As Integer = 0
  6. Dim thenum As Integer = 19
  7. ' Nice mess to print tags in numeric order down each column, left to right...
  8. ' Basically, start with first element, then skip 18 and put next, skip 18 put next, etc. and so forth...
  9. ' pdfText2a.Add is the function that's basically outputting the array element... to the PDF...
  10.     If thecount3 = 7 Then
  11.     thecount2 += 1
  12.     thecount3 = 0
  13.     pdfText2a.Add(theTagArray(thecount2 + (thecount3 * thenum)) & " | ")
  14.     thecount3 += 1
  15.     Else
  16.     pdfText2a.Add(theTagArray(thecount2 + (thecount3 * thenum)) & " | ")
  17.     thecount3 += 1
  18.     End If
  19.  
I want it to look kind of like this:

982000018301450 | 982000018561709 | ...
982000018561265 | 982000018561724 | ...
...
Though 7 across, 19 down.

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.
Mar 24 '08 #1
1 1102
Plater
7,872 Expert 4TB
So your output would be like:
Expand|Select|Wrap|Line Numbers
  1. 1 |  5  |  9 |
  2. 2 |  6  | 10 |
  3. 3 |  7  | 11 |
  4. 4 |  8  | 12 |
  5.  
What happens at page break? Should the first column go down to bottom of page and continue into 2nd column, then 3rd, 4th, etc until it must go to next page?
Mar 24 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Terry | last post: by
28 posts views Thread by Andy | last post: by
16 posts views Thread by Ben Hannon | last post: by
182 posts views Thread by Jim Hubbard | last post: by
25 posts views Thread by Sharrukin Amiri | last post: by
15 posts views Thread by Manny Chohan | last post: by
97 posts views Thread by Master Programmer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.