how do i open a com port and send a signal

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???
 
A

Adrian Jansen

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
 
T

Thomas Lutz

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.
 
A

Adrian Jansen

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
 
A

Adrian Jansen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top