Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending contents of a list box to a printer

Posted on 2010-08-13
3
Medium Priority
?
630 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

916 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