how do i open a com port and send a signal

  • Thread starter Thread starter Scott T Mc Bride
  • Start date Start date
S

Scott T Mc Bride

I need to be able to open a comm port and send a signal, how do i do this in
the visual basic editor???
 
Just like you always did in VB and QB:

Open "Com1:9600,n,8,1" for output as #1

Print #1,MySignal

Close #1

Substitute whatever Comport, speed and setup parameters you need for the
device
MySignal is a string containing whatever characters you want to send
Maybe suppress the trailing cr-lf from the print with a ;
You should also really use freefile to get a valid file handle, rather than
#1
There are several other caveats, but this might get you a start.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Doing serial communications in Access is not an easy task. You could
write VBA code that calls the Windows API to open a COM port however
it is extremely tricky and can be very time consuming.
A better way to do things is to use a tool that is designed
specifically for the job.

You might want to look at a product called WinWedge from TAL
Technologies at:
http://www.taltech.com/products/winwedge.html

It is a very simple tool to use and can have you up and running in
minutes.
 
Quick and dirty method:

In code behind a command button:

Open "Com1:9600,n,8,1" for output as #1

Print#1,"Your serial command"

Close #1

Adjust the serial parameters to suit your application.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Adrian,

I have no serial device to test this. How can I test this code to see if it is
working?

Steve
 
How do you test your code ? You need a computer to run the code on :-)

How do you test a serial port ? You need some serial hardware - like
another computer connected.


--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Back
Top