Ikuyy
Follower Engagement Pro
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
In this tutorial, we will going to create a program that will get and display all the computer ports in vb.net. COM Ports are serial communications port on a PC.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add only one Button named Button1 and labeled it as "Get Computer Ports". Insert a ListBox named ListBox1 for displaying all the COM Ports. You must design your interface like this:
3. Put this code in your Button1_Click. This will trigger to get and display all the available COM Port in the ListBox.
We have created a For Each loop statement that has the variable portName as String that has all the value of the Serial Port names. This For Each...Next Statement repeats this group of serial ports to be displayed in ListBox1 as we have the Add function of this control.
Output:
Download the source code below and try it! :)
For more inquiries just contact my number or e-mail below.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09488225971
Telephone: 826-9296
E-mail:[email protected]
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Visit my page on Facebook at: https://www.facebook.com/BermzISware
Download
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add only one Button named Button1 and labeled it as "Get Computer Ports". Insert a ListBox named ListBox1 for displaying all the COM Ports. You must design your interface like this:

3. Put this code in your Button1_Click. This will trigger to get and display all the available COM Port in the ListBox.
- Private
Sub
Button1_Click(
ByVal
sender As
System.
Object
, ByVal
e As
System.
EventArgs
)
Handles
Button1.
Click
- For
Each
portName As
String
In
My.
Computer
.
Ports
.
SerialPortNames
- ListBox1.
Items
.
Add
(
portName)
- Next
- End
Sub
We have created a For Each loop statement that has the variable portName as String that has all the value of the Serial Port names. This For Each...Next Statement repeats this group of serial ports to be displayed in ListBox1 as we have the Add function of this control.
Output:

Download the source code below and try it! :)
For more inquiries just contact my number or e-mail below.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09488225971
Telephone: 826-9296
E-mail:[email protected]
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Visit my page on Facebook at: https://www.facebook.com/BermzISware
Download
You must upgrade your account or reply in the thread to view hidden text.