Solved

Using the MSCOMM control with VB

Posted on 2003-11-25
3
528 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

730 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