DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009

    Question Combobox adding value to module HELP!

    Hello everybody,

    I have been trying to work this out for some time now but without any luck, this is my final hope.

    I have a script in Visual Studio which adds a network printer to a computer, I used to use VBS but I need to be able to add a GUI to it. This is the script in the module.

    Module Module1
    Sub add_printer()
    Dim objNetwork, strUNCPrinter
    strUNCPrinter = "\\peel-black\PDM-PTR-028"
    objNetwork = CreateObject("WScript.Network")
    End Sub
    End Module

    The bit which says "\\peel-black" is the server and "\PDM-PTR-028" is the printer.

    Is there a way to put all the names of the printers into a combobox and then when the value is selected on the combobox the value replaces the exsisting printer. PDM-PTR-028 would be a value in the combobox.

    I hope that somebody will be able to help me.

    Many Thanks In Advance


  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Welcome to DevX

    You will need to add your own error trapping.
    Imports System.Drawing.Printing
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim strInstalledPrinters As String
            For Each strInstalledPrinters In _
            ' Set the combo to the first printer in the list - optional
            ComboBox1.SelectedIndex = 0
    End Sub
    Public Sub add_printer(ByVal pstrPrinter As String)
    Dim objNetwork As ??????   'I do not know what you are doing here - in VB.NET 
                                         'this will generate an error.   You MUST 
                                         'stipulate a variable type
    Dim strUNCPrinter As String
    strUNCPrinter = "\\peel-black\" & pstrPrinter
    objNetwork = CreateObject("WScript.Network")
    End Sub
    Private Sub btnAddPrinter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddPrinter.Click
    End Sub
    Last edited by Hack; 04-06-2009 at 01:10 PM.

Similar Threads

  1. Replies: 3
    Last Post: 09-27-2007, 07:27 AM
  2. Adding ComboBox to a bound DataGridView
    By camrontucker in forum .NET
    Replies: 2
    Last Post: 03-10-2007, 12:02 PM
  3. adding a module to a project
    By harish13 in forum VB Classic
    Replies: 1
    Last Post: 07-27-2006, 02:44 AM
  4. Adding on to a ComboBox list
    By miss_jess in forum VB Classic
    Replies: 12
    Last Post: 05-31-2005, 09:33 AM
  5. Adding item to combobox
    By Eray Sazan in forum Web
    Replies: 0
    Last Post: 03-22-2001, 07:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.