FabulaTech Forum (https://www.fabulatech.com/forum/board-serialportcontrol-action-display-num-166870941.html)
Serial Port Solutions >> Serial Port Control >> Bug in .EventChar ??
(Message started by: mbinder on Sep 25th, 2009, 2:29am)

Title: Bug in .EventChar ??
Post by mbinder on Sep 25th, 2009, 2:29am
Hi,

i have several (5) instances of Serial Port Control object and want to close each connection if .EventChar=22 appears. Now it seems that all my connections closes if on any port .EventChar=22 appears even if on the other ports .EventChar=22 not appears.

Private Sub SPC_1_OnEventChar()
If SPC_1.EventChar = 22 Then
   SPC_1.Close
End If

It is easy to test when you read with one instance only one byte from buffer

Private Sub SPC_1_OnReceive(ByVal Count As Long)
k = SPC_1.ReadArray(buf, 1)

and with the other instances 20 bytes

Private Sub SPC_1_OnReceive(ByVal Count As Long)
k = SPC_1.ReadArray(buf, 20)

Would be nice if you can help me solve the problem. Sorry for my miserable english.

Title: Re: Bug in .EventChar ??
Post by Alex_Webster on Sep 28th, 2009, 1:43am
It's not a bug of Serial Port Control, it's feature of VB6.
When you create "several (5) instances of Serial Port Control object"
by simple copying of the object which is taken from the Toolbox - the same-name
massif of objects with the indexes from 0 to 4 (in your case) is created. But in
VB6 the names of event handlers are created in the following way: ObjectName_OnXXX, where XXX - is the event. In your case SPC_1_OnEventChar works out if Event char comes to any of COM ports. In order to "catch" the events
separately the Serial Port Control objects must have different names. So every
Serial Port Control object must be put on the Form from the toolbox directly.

In this case they will have the following names (a kind of): FTSPCControl1,
FTSPCControl2, FTSPCControl3 etc.
So accordingly the events will be FTSPCControl1_OnEventChar, FTSPCControl2_OnEventChar, FTSPCControl3_OnEventChar etc.

In case you still have any questions feel free to ask :)

Title: Re: Bug in .EventChar ??
Post by mbinder on Oct 18th, 2009, 11:29pm
Thalk you, works fine now.

Is there a list where the errornumbers are explained? For example what does error 87 mean?

Thanx.

Title: Re: Bug in .EventChar ??
Post by Alex_Webster on Oct 19th, 2009, 2:54am
All the errors you get using Serial Port Control are the system errors. Please look here: http://msdn.microsoft.com/en-us/library/ms681381%28VS.85%29.aspx