|
-
Apr 1st, 2010, 07:57 PM
#1
Thread Starter
Member
[RESOLVED] Using ONCOMM Event
I have searched the forum and found several several topics for using ONCOMM. I want to detect the arrival of data at the com port without polling nor do I want to wait for the data. Each received message will end with <ETX> &h03/chr$(3). Is this too ambitious?
-
Apr 1st, 2010, 11:17 PM
#2
Thread Starter
Member
Re: Using ONCOMM Event
Figured it out on my own. Thanks
-
Apr 2nd, 2010, 01:25 PM
#3
Lively Member
Re: Using ONCOMM Event
So, how dd you do it?
I am using similar end string - chr$(3) to end my incomming data.
And because I am a beginner in programming, I just want to see if I do it right.
Thanks.
-
Apr 2nd, 2010, 08:21 PM
#4
Thread Starter
Member
Re: Using ONCOMM Event
I set RThreshold = 1 and used the following code (some was taken from this forum):
Private Sub MSComm1_OnComm()
Dim strInput As String
With MSComm1
'test for incoming event
Select Case .CommEvent
Case comEvReceive
'display incoming event data to displaying textbox
strInput = .Input
Do Until Right$(strInput, 1) = Chr$(3)
strInput = strInput + .Input
Loop
SerialInASCII.Text = strInput
End Select
End With 'MSComm1
End Sub
'by setting RThreshold = 1, each byte is compared and added to the string strInput until chr$(3) is detected. This code may be cluggy to some but it works. By the way, I am novoice programmer myself and ask questions and search this forum reguarly. There are good people on this forum that want to help
-
Apr 3rd, 2010, 09:43 PM
#5
Re: Using ONCOMM Event
You would be wise to not use "+" to concatenate strings. The "&" char is the proper way to do it. 
Code:
strInput = strInput & .Input
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|