Solved

Sending contents of a list box to a printer

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
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…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
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…
Suggested Courses
Course of the Month7 days, 3 hours left to enroll

623 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