Solved

Print from a MultiSelsct ListBox

Posted on 2006-06-26
6
306 Views
Last Modified: 2008-03-03
I have a MultiSelect ListBox, I want to ba able to print all Items in that list box.

Example - Items in the listbox:

Burgers $1.20
Chicken Burger $1.50
Coka-Cola $ 0.95

I now want to print all these items on a receipt.........so far I can only print the first item

Please help
Ian wells

0
Comment
Question by:irwells
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 16983315
Ian,

What language are you dealing with ?  VB ?  C++ ?
0
 
LVL 12

Expert Comment

by:jkaios
ID: 16990068
Try this:

============================
Dim ii As Long
For ii = 0 To List1.ListCount - 1
  Printer.Print List1.List(ii)
Next
Printer.EndDoc
============================
0
 
LVL 12

Accepted Solution

by:
jkaios earned 250 total points
ID: 16990082
The ListBox is a collection, so you have to loop thru all the items in order to print them
using the "For...Next" loop structure as in the above example.

Just replace List1 with the name of your listbox control.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:irwells
ID: 16993578
I’m using VB, I’ve just tried your code and it works fantastic, thank you very much :-))

Ps Is there any way off printing the list without highlighting an item or having the items highlighted by default so all the operator need to do is press the print button??

0
 
LVL 12

Expert Comment

by:jkaios
ID: 16997828
The above example will print everything in the listbox without the need to highlight/select the items.

If you would like to print just the selected items then you would do something like this:

For ii = 0 To List1.ListCount - 1
  If List1.Selected(ii) = True Then
     Printer.Print List1(ii)
  End If
Next

This example best works on a ListBox with the "MultiSelect" property set to "Extended"
0
 

Author Comment

by:irwells
ID: 16999939
Yeah, sorry, it work fine........thanks you for helping me.
Ian wells
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 75
pairs challenge 5 66
PHP question(s) about order of output 9 57
Q2. How to run DAX query from SSMS. I don’t see any DAX query type. 1 48
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now