How to configure a USB port using visual basic

Written by jackson lewis
  • Share
  • Tweet
  • Share
  • Email

Visual Basic (VB) is a well-known event-driven programming language that is a major component of Microsoft's .NET programming environment. Visual Basic is backwards compatible with the COM programming model and is best known for incorporating predefined user interface components that permit programmers to create graphical user interfaces (GUI's) for programs in a significantly reduced amount of time. You can also configure USB port information using Visual Basic's access to the COM programming model.

Skill level:

Other People Are Reading


  1. 1

    Open a your Visual Basic project in your Integrated Development Environment. Once your project is loaded, open the programming window for the section of you program you desire to configure the USB device communications port.

  2. 2

    Create a new class member that extends the System.IO.Ports.SerialPort with the following code statement: Friend SelectedPort As System.IO.Ports.SerialPort

  3. 3

    Create a handle to the computer's serial port. A handle will allow you to access the data associated with the port and change the configuration information. Enter the following code to create the serial port handle: selected Port = My.Computer.Ports.OpenSerialPort( "COM4", 9600, Parity.None, 8, StopBits.One)

  4. 4

    Confirm the connection to the USB serial port is operational. To do this, enter the following code: selectedPort.Handshake = Handshake.RequestToSend

  5. 5

    Change the read and write timeout configuration variables of the USB serial port. The settings are made in milliseconds, so a value of 1000 is approximately one second. The code to configure the read and write timeout settings is: selectedPort.ReadTimeout = 1000 selectedPort.WriteTimeout = 1000

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.