|
-
Nov 29th, 2000, 10:10 AM
#1
Okay... this is probably going to be long but I need to explain what I am trying to do...
In the app I am working on, I have done printing through crystal reports. I basically made a copy of the forms in CR and am manually populating the fields when the user clicks print. The main meat of the form is an arbitrary number of items (coming from a listview box on the form). Because there is no set limit to the number of items, I have it printing 14 items per printed page for as many pages as it takes. The problem is that one of the fields on the item line may take up more than one line itself of printed paper (and the description may intentionally take up more than one line... such as when a computer is purchased there would be a descrption of components). So on the printed report, you may have one item taking up any number of lines.
The string manipulation itself to split up a line I think I can manage.
What I am having a hard time with is somehow, as generically as possible, wrapping the description of an item onto the next line. I have simplified the problem by creating an array of a user defined data type (each item representing a single line on the printed report).
What I really need to do is have some kind of function or block of code that can take in a string, and somehow split it into an unknown number of strings. It would seem that some kind of recursion would be best suited to do something like this, but how would I do it?
Storage() is the array of item lines
LineCounter is the line # of the current listview entry
Ofset is a running total of lines that have been wrapped onto the next line. I.E....
lstview item 1 takes 2 printed lines
lstview item 2 takes 1 line
Then for Lstview item 3, linecounter would = 3, offset = 1
linecounter + offset = 4, so listview item 3 would start on the 4th line of the printed report.
Private Sub StringChunk(Storage() As ItemLine, LineCounter as Integer, Offset As Integer)
'split the string into str1 and str 2
storage(offset + linecounter).Description = str 1
increment offset
if str2 fits on one line then
increment itemline
Else
StringChunk (Storage(), linecounter, offset)
end if
End Sub
Would something like this be viable?
Thanks if you have read this far. I think just explaining it has helped..... now I have an idea of how I could do this recursively. Any thoughts and comments would be much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|