Solved

Sending contents of a list box to a printer

Posted on 2010-08-13
3
587 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
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 500 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

743 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

11 Experts available now in Live!

Get 1:1 Help Now