MSCOMM control

giang
09-05-2001, 05:52 PM
Dear All, this is my exam code :

Private Sub MSComm1_OnComm()
Dim sData As String ' Holds our incoming data
If MSComm1.CommEvent = comEvReceive Then
sData = MSComm1.Input
sData = Mid(sData, 5, 8) 'get 5 bytes from data received
lstReceive.AddItem (sData)
ElseIf MSComm1.CommEvent = comEvBreak Then
lstReceive.AddItem ("Break Event")
End If
End Sub

And I receive Break Even more than Receive Event

Thanks for your reply !!!

Thanks very much

<P ID="edit"><FONT class="small"><EM>Edited by giang on 09/05/01 07:59 PM.</EM></FONT></P>

BillSoo
09-05-2001, 06:06 PM
I'm not exactly sure what you are asking....

It sounds like you need to receive the bytes in the ONCOMM event....



"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

Jared
09-05-2001, 06:22 PM
There are two main methods of receiving serial data using the MSComm control. You can either use the OnComm event, or you can poll the buffer by using timer.

Check out the articles I have written at:
http://vboverdrive.extreme-vb.net/articles.php3

If you have any more questions, feel free to ask...


Jared Hoylman
VB Overdrive
http://vboverdrive.extreme-vb.net/main.php3

basdewaard
09-05-2001, 06:25 PM
i'm working with the mscomm control at the moment. i've attached a file that 'may' help. it contains a list of possible errors in which you can add your own error handling code (it's from the MSDN library).

why don't you post a copy of your code?


<font color=blue> :: grin-r :: </font color=blue>

basdewaard
09-05-2001, 08:56 PM
grrrr. this is starting to look like the impossible...

i'm using two bits of proprietry software: 1 dials a phone number and establishes a connection, the other then takes over the port scanning processes and runs a DDE.

i'm trying to replace the program that dials the phone number (it isn't flexible enough). i've used the mscomm control to establish a connection......no problems there. where i'm struggling is when i try to run the second program (that runs the DDE), it comes back with an error "com port already in use" - fair enough!

the big question is: "how do i hand over the com port to another application by using the mscomm control???". closing the port is no good because it hangs up the connection.




<font color=blue> :: grin-r :: </font color=blue>

BillSoo
09-05-2001, 10:45 PM
I'm not sure....but there may be a way to configure your modem such that closing the port doesn't hang up the line. If so, you could open the port, dial, close the port. Run the other app which opens the port and connects to the already connected line. Check your modem manual for the Hayes AT commands...


"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

basdewaard
09-07-2001, 06:38 PM
thanks for the suggestion BillSoo. i haven't had any luck though! i spent all day at work yesterday stuffing around with this one. i even asked our 'communications expert' who told me it wasn't possible to send that sort of AT commands to the modem.

has *anyone* got any other suggestions? i'm thinking of maybe using an alternative to mscomm but i'm far from experienced in this area.


<font color=blue> :: grin-r :: </font color=blue>

Derek Stone
09-07-2001, 06:55 PM
The last time I saw a "port handoff" was a long time ago... and it used a nasty vitual driver that was far from friendly.
I'd investigate into other, more advanced, comm controls, as you had suggested.
I doubt however there is an easy answer to this one.

Good Luck
-cl

basdewaard
09-08-2001, 01:53 AM
thanks cl. that's just boosted my motivation to nail this one images/icons/smile.gif


<font color=blue> :: grin-r :: </font color=blue>

Jared
09-09-2001, 01:28 AM
In the code you showed, you used the Constant "comEvBreak" This constant does not exsist, but "comEventBreak" does.

comEventBreak = 1001

If you are not using "Option Explicit" at the top of your modules then "comEvBreak" will be defined as a variant variable with the value of zero by default.

So maybe when the OnComm event fires with whatever event has the value of zero, you are thinking you are getting a "Break" signal....

Hopefully this will solve your problem...


Jared Hoylman
VB Overdrive
http://vboverdrive.extreme-vb.net/main.php3

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum