• We just launched and are currently in beta. Join us as we build and grow the community.

Get and Display all Computer Ports in VB.NET

Ikuyy

Follower Engagement Pro
I Rep
0
0
0
Rep
0
I Vouches
0
0
0
Vouches
0
Posts
69
Likes
187
Bits
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:

portdesign.png


3. Put this code in your Button1_Click. This will trigger to get and display all the available COM Port in the ListBox.
  1. Private

    Sub

    Button1_Click(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    Button1.

    Click
  2. For

    Each

    portName As

    String

    In

    My.

    Computer

    .

    Ports

    .

    SerialPortNames
  3. ListBox1.

    Items

    .

    Add

    (

    portName)
  4. Next
  5. 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:

portoutput.png


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.
 

452,292

323,341

323,350

Top