Solved

Using the MSCOMM control with VB

Posted on 2003-11-25
3
520 Views
Last Modified: 2010-05-03
Hi

I'm working with a handheld device at present that has a serial connection to enable the download of information from the device to a PC.  Having programmed the device to send the data that is collected, I'm not looking at the PC app to collect that data.

I have used HyperTerminal for a basic check to ensure some data is being passed from the device through the COM port to the PC and everything 'looks' ok there.

My problem is that when I try to use the MSCOMM control, for some reason as data is sent from the device, it doesn't seem to raise an onComm event and therefore I'm unable to effectively grab the data.  If is have a loop just waiting for MSComm1.Input, I get some data back.

What am I doing wrong?  Any ideas?

Regards
Simon.
0
Comment
Question by:sbennetts
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 125 total points
ID: 9817054
Hi sbennetts,

The most likely reason is that you have not set the .RTHreshold property of the mscomm control. This governs when the OnComm event is fired. By default it is zero which means you have to poll it for information. If you set it to 1 or higher then the OnComm event will be fired when there are this number of bytes in the inbuffer.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 2

Author Comment

by:sbennetts
ID: 9817072
Your a star!  Thanks, presumably if I'm reading 'records' of 24 bytes, I can set it to 24 so that it grabs a 24 byte buffer for me.  Thanks for the quick response.
Simon.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 9817101
sbennetts

Indeed that is correct, it should then fire when you have a full 24 byte bunch of data.

Tim.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now