Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

About Mscomm Control programming(Serial Port)

124 views
Skip to first unread message

Alex Lu

unread,
Jul 16, 2002, 11:27:50 PM7/16/02
to
Dear All,
I try to write a VB program to listen to the input data from serail port
barcode scanner!I use the code as follows:

Dim buffer As String

Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.PortOpen = True
MSComm1.InBufferCount = 0
MSComm1.OutBufferCount = 0
End Sub

Private Sub MSComm1_OnComm()
buffer = buffer + MSComm1.Input
End Sub

I can not get any character from serial port by this program, but I can
receieve the character data while I use the HyperTerminal client!
Could you tell me the reason? Any helpful idea would be highly
appreciated!

Best Regards
Alex Lu

Gerd Molkens

unread,
Jul 17, 2002, 1:15:52 AM7/17/02
to
You also have to set the property 'RThreshold'. If this is
0 then the OnComm-event will not be triggered. Look in the
helpfiles for more information.

Gerd

>.
>

Gerd Molkens

unread,
Jul 17, 2002, 1:15:05 AM7/17/02
to
You also have to set the property 'RThreshold'. If this is
0 then the OnComm-event will not be triggered. Look in the
helpfiles for more information.

Gerd

>.
>

rdp

unread,
Jul 23, 2002, 11:02:00 PM7/23/02
to
Alex,

I did not notice any setting for the property of handshaking. The
device
may or may not require handshaking. Note the hardware wiring for the
device and note if there are any references to RTS or CTS. It may need
XON/XOFF - check in documentation. Settings of DTREnable, RTSEnable and
Handshaking could be affected. After knowing this, and verifying
that the wiring is right, try again. I do not leave many properties to
chance.

Software handshaking settings:

If comSerial.PortOpen = False Then 'Only open if shut
comSerial.InBufferCount = 0 'Clear buffer
comSerial.RThreshold = 1 'Tell me about every
char
comSerial.CommPort = txtPort.Text 'Set port #
comSerial.Settings = txtSettings.Text 'Grab setting
comSerial.InBufferSize = IBUFSIZE 'set buffer - size pick
your size
comSerial.OutBufferSize = OBUFSIZE
comSerial.Handshaking = comXOnXoff
comSerial.PortOpen = True 'Go - open port
End If
This is in addition to setting on the property pages
DTREnable = True
EOFEnable=False
NullDiscard=False
ParityReplace=?
RTSEnable=False

I have been using the control for HW or SW handshaking (or Both)
using a direct connection or a modem for several years with few
problems.
Used for bar code scanners, RFID units, dedicated equipment, etc.
If only mscomm could handle modems using TAPI .......
Switched to SAX control for that.

Thanks,
rick

Champer

unread,
Nov 13, 2002, 12:41:07 PM11/13/02
to
You must set your lengths to greater than 0 or the OnComm event is not
fired. As you are set up right now, you must start a loop containing
the .input property to catch data.

On Wed, 17 Jul 2002 11:27:50 +0800, "Alex Lu" <rhine...@yahoo.com>
wrote:

0 new messages