Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 27th, 2008, 06:42 PM
Registered User
 
Join Date: Oct 2008
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old October 29th, 2008, 01:56 AM
Friend of Wrox
Points: 2,950, Level: 22
Points: 2,950, Level: 22 Points: 2,950, Level: 22 Points: 2,950, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 788
Thanks: 1
Thanked 51 Times in 47 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)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 03:40 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.