Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending contents of a list box to a printer

Posted on 2010-08-13
3
Medium Priority
?
624 Views
Last Modified: 2013-12-24
VB6 under XL:

I have an application that computes some stuff, and displays it in a list box, item by item.
I would like to send the contents of the list box to a printer.

I wrote a routine:
Public Function GetDefaultPrinter() As String
It seems to work just fine. It either returns the printer, or "Not Found".

On the form containing the list box, I have a command button: cmdPrint with the associated sub:
cmdPrint_Click()

Question: How do I send the contents of the list box to the printer? Code to go into the Click Sub

Comment: For this purpose, a List Box may not be the best container for the computed data.
0
Comment
Question by:NormaPosy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33435211
Here is a quick reference:

http://www.vb6.us/tutorials/printing-vb6-using-printer-object

It walks you through to print a text file line by line. You can just change the lines of the text file with the items of your listbox.

Here is another quick tutorial:
http://www.devarticles.com/c/a/Visual-Basic/Printing-With-Visual-Basic/1/

0
 
LVL 5

Accepted Solution

by:
Leithauser earned 2000 total points
ID: 33436564
This will do it.
Dim X as Integer
For X = 0 To List1.ListCount -1
      Printer.Print List1.List(X)
Next X
Printer.EndDoc
This assumes the List box is called List1. You can change that as necessary. Note taht this automatically uses the default pritner, so you do not need to find out which printer it is.
 
0
 

Author Closing Comment

by:NormaPosy
ID: 33438051
Thank You
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
Suggested Courses

715 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