Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PRINT listview in tabular and formatted text 3

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
411
0
16
IT
i have a listview with data in image.

i need to send the value to the printer in a tabular mode...

the param are:

max lenght for each row 60 character max

for

REPARTO max lenght 34 align to the left
ID max lenght 3 align to the center
qty max lenght 3 align to the center
PREZZO max lenght 10 align to the right
TOT. max lenght 10 align to the right

max lenght of each row 34+3+3+10+10

possible?
 
 https://files.engineering.com/getfile.aspx?folder=ed023410-f725-48e3-8ca2-e990f8f18037&file=SCO.jpg
Dim listy As ListItem

For Each listy In ListView1.ListItems
Debug.Print listy; Tab(34);
Debug.Print Spc((3 - Len(listy.ListSubItems(1))) / 2); listy.ListSubItems(1); Tab(38);
Debug.Print Spc((3 - Len(listy.ListSubItems(2))) / 2); listy.ListSubItems(2); Tab(41);
Debug.Print Spc(10 - Len(listy.ListSubItems(3))); listy.ListSubItems(3); Tab(51);
Debug.Print Spc(10 - Len(listy.ListSubItems(4))); listy.ListSubItems(4)
Next
 
no dubt!
Stringm you are a genius!
Tks.
 
OPS...

possible to print also a header title of each column of listview , to the head of row?
 
[tt][pre] Dim listy As ListItem

With ListView1
Debug.Print .ColumnHeaders(1); Tab(34);
Debug.Print Spc((3 - Len(.ColumnHeaders(2))) / 2); .ColumnHeaders(2); Tab(38);
Debug.Print Spc((3 - Len(.ColumnHeaders(3))) / 2); .ColumnHeaders(3); Tab(41);
Debug.Print Spc(10 - Len(.ColumnHeaders(4))); .ColumnHeaders(4); Tab(51);
Debug.Print Spc(10 - Len(.ColumnHeaders(5))); .ColumnHeaders(5)
End With


For Each listy In ListView1.ListItems
Debug.Print listy; Tab(34);
Debug.Print Spc((3 - Len(listy.ListSubItems(1))) / 2); listy.ListSubItems(1); Tab(38);
Debug.Print Spc((3 - Len(listy.ListSubItems(2))) / 2); listy.ListSubItems(2); Tab(41);
Debug.Print Spc(10 - Len(listy.ListSubItems(3))); listy.ListSubItems(3); Tab(51);
Debug.Print Spc(10 - Len(listy.ListSubItems(4))); listy.ListSubItems(4)
Next[/pre][/tt]
 
Instead of ListView, I would be tempted to do it with MSFlexGrid (or MSHFlexGrid) instead.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Maslow said:
I suppose it is tempting, if the only tool you have [know] is a hammer, to treat everything as if it were a nail.

Myself, I like to use a screwdriver from time to time when screws are used, or a wrench when nuts and bolts are involved. :)

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I don't disagree, Andy. But why - in this specific case - do you think an MSFlexgrid would be a better choice?
 
MSFlexgrid may not be a 'better' choice, just a different approach to display the data for the user to choose from. And there are a lot of help on the Web of how to use it.

sal21 said: "i love it" ('it' being Listviews) I love (well, like) to use controls I am familiar with, I know how to use them and don't have to ask for help. [hint]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I can have to the left, of printer.print, this value:

strvar="PAGAMENTO ELETTRONICO:"
or
strvar="PAGAMENTO CONTANTI:"
or
strvar="RESTO:"

ecc...

and a var strnumber="0,25"

the max leght of string, to print, is 60.

now, based the strvar, i need to printer.print, similar:

strvar<(align to the left) strnumber<(to align to the right)

naturally strnumber have a variable lenght(11,58, 5,48, 650,45 ...ecc)

how to?




 
Hard to decipher your requirements, but my guess would be:

Code:
Const MAX_LENGTH As Integer = 60
Dim strvar As String
Dim strnumber As String

strvar = "RESTO:"
strnumber = "0,25"
 
Debug.Print strnumber & Space(MAX_LENGTH - (Len(strvar) + Len(strnumber))) & strvar

To get as an outcome:[blue]
[pre]0,25 RESTO:[/pre][/blue]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Andy, tks.
but i need eaxclly the opposite:

RESTO: 0,25
 
Swap it around:

Code:
Debug.Print strvar & Space(MAX_LENGTH - (Len(strvar) + Len(strnumber))) & strnumber

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Or

Code:
Debug.Print strvar & Format(strnumber, String(MAX_LENGTH - Len(strvar), "@"))
 
andy & strongm...
my angels!
tks

2009luca and sal21, are
it's always me.

have 2 account:)
 
POSSIBLE to print this lines in listbox... instaed to send a printer

...
Printer.Print .ColumnHeaders(1).Text; Tab(34);
Printer.Print Spc((3 - Len(.ColumnHeaders(2).Text)) / 2); .ColumnHeaders(2).Text; Tab(38);
Printer.Print Spc((3 - Len(.ColumnHeaders(3).Text)) / 2); .ColumnHeaders(3).Text; Tab(41);
Printer.Print Spc(10 - Len(.ColumnHeaders(4).Text)); .ColumnHeaders(4).Text; Tab(51);
Printer.Print Spc(10 - Len(.ColumnHeaders(5).Text)); .ColumnHeaders(5).Text
....
 
Is that a question? If so, yes, you can send to a printer instead. Need to finish with Printer.EndDoc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top