Jul 30th, 2010, 2:10am
   FabulaTech Forum
   Serial Port Solution
   Serial Port Control
(Moderators: George_White, Alex_Webster, Mike, Andrew)
   Bug in .EventChar ??
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Print Print
   Author  Topic: Bug in .EventChar ??  (Read 22 times)
mbinder
FabulaTech Forum Newbie
*





   
View Profile

Posts: 4
Bug in .EventChar ??
« on: Sep 25th, 2009, 2:29am »
Quote Quote Modify Modify

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.
IP Logged
Alex_Webster
FabulaTech Forum Moderator
FabulaTech Forum Full Member
*****






   
View Profile WWW Email

Gender: male
Posts: 211
Re: Bug in .EventChar ??
« Reply #1 on: Sep 28th, 2009, 1:43am »
Quote Quote Modify Modify

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 Smiley
IP Logged
mbinder
FabulaTech Forum Newbie
*





   
View Profile

Posts: 4
Re: Bug in .EventChar ??
« Reply #2 on: Oct 18th, 2009, 11:29pm »
Quote Quote Modify Modify

Thalk you, works fine now.
 
Is there a list where the errornumbers are explained? For example what does error 87 mean?
 
Thanx.
IP Logged
Alex_Webster
FabulaTech Forum Moderator
FabulaTech Forum Full Member
*****






   
View Profile WWW Email

Gender: male
Posts: 211
Re: Bug in .EventChar ??
« Reply #3 on: Oct 19th, 2009, 2:54am »
Quote Quote Modify Modify

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
 
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Print Print

« Previous topic | Next topic »