Hi everybody,
This is my first posting.
I did some VB6 many years ago. I am finding hard now to do any coding now.
I have manged to stitch togheter a bit of code, from examples from this forum.
I am working on a project that when finished should read data from a digital muntimeter.
The code below is at very beginning of the project and I need your help with this.
I need to fill ComboBox1 only Com port that are available to use.
How do I modify the code below to achieve that?
I am using VB.net 2010.
Regards
Francesco :)
This is my first posting.
I did some VB6 many years ago. I am finding hard now to do any coding now.
I have manged to stitch togheter a bit of code, from examples from this forum.
I am working on a project that when finished should read data from a digital muntimeter.
The code below is at very beginning of the project and I need your help with this.
I need to fill ComboBox1 only Com port that are available to use.
How do I modify the code below to achieve that?
I am using VB.net 2010.
Regards
Francesco :)
Code:
Public Class Main
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Detect available ports and store them in the Ports array
For Each Port As String In IO.Ports.SerialPort.GetPortNames
Dim myPort As New IO.Ports.SerialPort(Port)
ComboBox1.Items.Add(Port)
Next
'Populate combo box
ComboBox1.SelectedIndex = 0 'Select first COM port in the list
If Button1.Text Is "Open Port" Then
SerialPort1.Open()
Button1.Text = "Close Port"
Button2.Enabled = True
ElseIf Button1.Text Is "Close Port" Then
SerialPort1.Close()
Button1.Text = "Open Port"
Button2.Enabled = False
End If
End Sub