Fill a combobox with current defined printers

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Add this code to an empty form with a combobox or list box on it:

private Sub Form_Load()
    Combo1.Clear
    m_GetPrinters Combo1
    Combo1.ListIndex = 0

End Sub

'-----------------------------------------------------------------
' looking for all printers and filling objListOrCombo
'-----------------------------------------------------------------
public Sub m_GetPrinters(byref objListOrCombo as Object)
    Dim objPrinter          as Printer
    Dim intNbOfPrinters     as Integer

    intNbOfPrinters = Printers.Count - 1
    for Each objPrinter In Printers
        objListOrCombo.AddItem objPrinter.DeviceName
    next
End Sub

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read