Jun 11, 2012 I'm doing this project with Visual Basic, where in I have an external prototype that needs to transmit data, We will be using a serial to USB cable. I need to build a PC based program in VB that will get the data being thrown by the microcontroller(the project is chess tracking, and we need to get the data tracked.) How will I start the program? Serial-port-vb.doc 1 2/1/2010 Serial Port Using Visual Basic.NET and Windows Introduction The serial (COM) port is one of the simplest ways to communicate between a PC and a microcontroller circuit. Most microcontrollers have hardware serial ports and most.
-->This topic describes how to use
My.Computer.Ports
to send strings to the computer's serial ports in Visual Basic.Example
This example sends a string to the COM1 serial port. You may need to use a different serial port on your computer.
Use the
My.Computer.Ports.OpenSerialPort
method to obtain a reference to the port. For more information, see OpenSerialPort.The
Using
block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block or within a Try...Catch...Finally
block.The WriteLine method sends the data to the serial port.
Compiling the Code
![Visual Basic Serial Port Programming Visual Basic Serial Port Programming](/uploads/1/2/4/9/124905958/765957755.jpg)
- This example assumes the computer is using
COM1
.
Robust Programming
This example assumes the computer is using
COM1
; for more flexibility, the code should allow the user to select the desired serial port from a list of available ports. For more information, see How to: Show Available Serial Ports.This example uses a
Using
block to make sure that the application closes the port even if it throws an exception. For more information, see Using Statement.See also
![Visual Visual](/uploads/1/2/4/9/124905958/227133071.jpg)
Active4 years, 11 months ago
I am working with a laboratory machine (cobas 6000) to implement LIS using VB6. The machine has a COM port (9 pin).
How can I read the data from machine to my software and write my software data to machine through COM Port?
Tiago SippertHow can I read the data from machine to my software and write my software data to machine through COM Port?
Vb6 Serial Port Programming
1,30177 gold badges2121 silver badges3030 bronze badges
user2542220user2542220
Visual Basic Serial Port Example
1 Answer
You should have a look at the MSComm control for VB6.
This allows you to read and write data on a serial port:
An example project is here:
Matt WilkoMatt Wilko23.2k1010 gold badges7474 silver badges122122 bronze badges