Results 1 to 10 of 10

Thread: picking a serial port on WM

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    78

    picking a serial port on WM

    Hi,

    I'm trying to get the comPorts from a mobile device:
    HTML Code:
    My.Computer.Ports.SerialPortNames.Count - 1
    But I get an error
    HTML Code:
    computer is not a member of my vb net
    Or if you know another method of picking (at running time), a Serial Port on a mobile device, please let me know.

    Thanks.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: picking a serial port on WM

    Thread moved from the 'VB.Net' forum to the 'Mobile Development' forum

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: picking a serial port on WM

    Code:
        Private Function foo() As String()
            Return IO.Ports.SerialPort.GetPortNames 'return the serial port names on this computer
        End Function
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    78

    Re: picking a serial port on WM

    Thanks for the answer,
    but how do I use it????

    Regards

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: picking a serial port on WM

    I answered when this was in the VB forum. Any answer I would give may or may not be accurate for your environment. You should be clear in your questions.

    "...but how do I use it????" "It" is?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6
    Fanatic Member
    Join Date
    Sep 2009
    Location
    Lakewood, Colorado
    Posts
    621

    Re: picking a serial port on WM

    Code:
    Dim PortNames () As String
    Dim SerialPort as New System.IO.Ports.SerialPort  'or use the SerialPort control
    PortNames = SerialPort.GetPortNames()
    For I As Integer = 0 To PortNames.Length -1
       TextBox1.SelectedText = PortName(I) & vbCrLf  'or add PortNames to a ListBox, for example
    Next I
    Dick
    Richard Grier, Consultant, Hard & Software
    Microsoft MVP (Visual Basic)

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    78

    Re: picking a serial port on WM

    Thanks DickGrier

    it works OK now

    Regards

  8. #8
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: picking a serial port on WM

    I missed what you were trying. You could use a combobox

    Code:
            ComboBox1.Items.AddRange(IO.Ports.SerialPort.GetPortNames)
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    78

    Re: picking a serial port on WM

    Code:
    AddRange is not a member of Sys..............ComboBox.ObjectCollection
    Still using Dick's solution.

    Thanks.

  10. #10
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: picking a serial port on WM

    I keep forgetting that you are on a different platform. Sorry.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width