Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2008, 06:42 PM
Registered User
 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create a list box containing available printers

Greetings,

As you can see from the water still dripping from behind my ears I am new to VB. I need to create an app that allows a user to select a desired printer from a list box. I do not want to use the PrintDialog control (it contains more information and prompts then required).

Please help.

Thank you

 
Old October 29th, 2008, 01:56 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Here is a possible hint :

Dim prn As Printer

Set prn = Printer

Populate Printers in the List Box and add the Index in List's ItemData

iPrn = 0
For Each p In Printers
    lstPrnDraw.AddItem p.DeviceName
    lstPrnDraw.ItemData(lstPrnDraw.ListCount - 1) = iPrn
    iPrn = iPrn + 1
Next p


Here I am getting the selected printer :


Private Sub cmdOK_Click()

For iPrn = 0 To lstPrnDraw.ListCount - 1
    If lstPrnDraw.Selected(iPrn) = True Then
       Set prn = Printers(lstPrnDraw.ItemData(iPrn))
       Exit For
    End If
Next iPrn

End Sub



http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
List the Available printers ajit Java Basics 2 May 4th, 2007 07:54 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.