-
Jul 1st, 2011, 06:03 AM
#1
Thread Starter
Lively Member
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.
-
Jul 1st, 2011, 06:21 AM
#2
Re: picking a serial port on WM
Thread moved from the 'VB.Net' forum to the 'Mobile Development' forum
-
Jul 1st, 2011, 06:25 AM
#3
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
-
Jul 1st, 2011, 07:12 AM
#4
Thread Starter
Lively Member
Re: picking a serial port on WM
Thanks for the answer,
but how do I use it????
Regards
-
Jul 1st, 2011, 11:06 AM
#5
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?
-
Jul 2nd, 2011, 11:39 AM
#6
Fanatic Member
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)
-
Jul 4th, 2011, 05:15 AM
#7
Thread Starter
Lively Member
Re: picking a serial port on WM
Thanks DickGrier
it works OK now
Regards
-
Jul 4th, 2011, 09:52 AM
#8
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)
-
Jul 5th, 2011, 07:43 AM
#9
Thread Starter
Lively Member
Re: picking a serial port on WM
Code:
AddRange is not a member of Sys..............ComboBox.ObjectCollection
Still using Dick's solution.
Thanks.
-
Jul 5th, 2011, 09:36 AM
#10
Re: picking a serial port on WM
I keep forgetting that you are on a different platform. Sorry.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|