How can i read from RS232 using a macro (VB)?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i would like to write a macro (Excel) in vb that would enable me to read from
rs232 port, but i don't know how to do it. can anyone help me please.
 
the first one says it is free, the second is $59 or $59.85 (it says both. )

You also might look at the mscomm control. Seach this newsgroup for mscomm
 
You might also try the "rsapi.dll" which was coded by H.-J. Berndt
([email protected]) for the book "Measurement and control using Word &
Excel - VBA macros for the serial interface".

http://home.t-online.de/home/H.Kainka/rsapidll.zip

The zip file contains the rsapi.dll for 16- and 32-bit windows systems from
the book:

"H.-J. Berndt / B. Kainka
Messen, Steuern und Regeln mit Word und Excel
VBA-Makros f?r die serielle Schnittstelle, 2., neubearb. und erw. Aufl.
Franzis-Verlag GmbH, 85586 Poing, 1999 ISBN 3-7723-4093-8"

You probably also need the updated dll which fixes some issues under
windows 2000 and xp: http://www.hjberndt.de/soft/rsapitest.zip

Example usage:

Declare Function OPENCOM Lib "RSAPI.DLL" (ByVal Parameter$) As Integer
Declare Sub CLOSECOM Lib "RSAPI.DLL" ()
Declare Function READBYTE Lib "RSAPI.DLL" () As Integer

Sub Main()
OPENCOM ("COM2,19200,N,8,2")
x = READBYTE
CLOSECOM
End Sub

For the serial interface the DLL has the following functions:

OPENCOM - open serial interface
CLOSECOM - close serial interface
SENDBYTE - submit a single byte
READBYTE - read a single byte
SENDSTRING - send a string of bytes
READSTRING - read a string of bytes
TIMEOUT - set the max. timeout delay
RTS - set the rts line status
DTR - set the dtr line status
TXD - set the txd line status
CTS - read the cts line status
DCD - read the dcd line status
DSR - read the DSR line status
RI - read the ri line status

The DLL is free to use but with commercial projects the author asks to be
mentioned along with the book title.

Regards,
R. Gaida
 
Back
Top