- SerialPort brief Example This sample is to accompany the blog at:http://charpcoder.wordpress.com/2011/12/21/serial-port-programming-part-1a-very-brief-introduction.
- Reading/Writing data via COM Port in VB6. Ask Question 0. I am working with a laboratory machine (cobas 6000) to implement LIS using VB6. The machine has a COM port (9 pin). VB6 Serial port programming. How to read from two COM ports? Read from COM port in C#.
- Visual Basic Serial Port Programming Arduino
- Windows Serial Port Programming
- Visual Basic Serial Port Programming
What is the best way to access a serial port from VBA?
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. Processing Serial Port Number Programming and Selecting Posted on July 22, 2015 by Starting Electronics Processing language applications that use the serial port to connect to serial devices such as Arduino need to use the correct serial port number that the serial device is connected to. Hello folks, Visual Basic.net is an easy to learn language from Microsoft for the windows platform.One of the cool features of Visual Basic.net is the ability to whip up good looking gui components with a few lines of code. In this tutorial we are going to use Visual Basic.net to program your PC's Serial Port and communicate with an embedded microcontroller like MSP430 or 8051.
I have a need for some of our sales reps to be able to send a simple string over the serial port from an action button in PowerPoint. I don't commonly use VBA, especially for anything like this. Normally I would turn it into an application of some sort, but I actually don't think the idea is that bad. It will be a handy tool for them to demo this device with while on a projector and talking to other sales guys and non technical people. Also, this sales guy will have no problem making small modifications to the VBA or PowerPoint presentation, but would not do as well with recompiling a .NET application.
I know we could do it through a batch file run from the presentation on the action, but that doesn't make me very happy. I figure we could probably access a COM object and run from there, but again I am not real up on the latest and greatest libraries to use in VBA, and it would also be nice to get a quick little primer in how to easily open, send and close the connection.
Since this will need to be run on multiple people's computers, it would be nice if it would be easily transportable to other machines. I should be able to say it has to run on Office 2007 and Windows XP. Compatibility with anything else would be a nice bonus though.
How should I go about handling this? Any good tips or tricks? Library recommendations?
3 Answers
The Win32 API handles the serial port as a file. You can access the serial ports directly by calling these API functions from within VBA. I had to do this for an old .NET application but VBA is no different.
Rather than hash it out for you on this site, here's a reference I've hung onto over the years. How to perform serial port communications in VBA
This works for me. I'm not sure if the OPEN actually sets up the Baud rate, as I first used TeraTerm.My COM port is a USB connection to a BASYS3 prototyping kit. It is spewing characters at 9600, records of 36 characters ending with CR. I can randomly send commands of 9 characters. In the above code, I generate these command strings every time I have received a new line.The way I chose which character to send is a little clunky: perhaps a better way is to have a character pointer and a number of characters, and when those go equal to set them both to zero.
ppovoskiHere is a brief module of VBA code that can send and receive messages on a PC serial port. This is not very elegant, but it is simple and should work on modern versions of Excel and Windows.
You are left on your own to expand the functionality and store or parse the messages. This just shows the low-level stuff to deal with the serial port.
The first 5 lines declare the millisecond 'Sleep' library function (based on Excel version).
Visual Basic Serial Port Programming Arduino
The SerialPort() subroutine outlines the steps to open the port, transmit some data, receive some data, try again to receive some data (to show that it really does not run afoul of the 'end of file' error), and close the port.