Solved

Sending contents of a list box to a printer

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

837 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