Solved

MSComm Control Blues

Posted on 1999-01-07
4
198 Views
Last Modified: 2013-12-26
Hi, my problem is this.  I am storing data coming from a device through my serial port.  Easy huh!  I have viewed the data using the hyper terminal and everything comes in line by line.  Great!  I have my application stroing the data into an Access table and it works great.  However, the data is broken into two different parts.  Well, then I removed all the code dealing with Access and used the immedate window to view what was coming across.  AHHHHH!  What's going on?  The hyper terminal shows the data coming in line by line as such :
PORT  1 MAT    2 OFF LINE         JAN 07, 1999  09:21:23

It looks great in hyper terminal! But why when I view it in the immediate window, it comes across like this

PORT  1 MAT    2 OFF LINE  
        JAN 07, 1999  09:21:23
These are two seperate lines.  I increased the buffer size and made sure that the inbuffer count was big enough to accept this string.  Now I have two records in Access.  Help, I have exhausted my documentation.  Please.
0
Comment
Question by:Nelmarcas
  • 2
4 Comments
 
LVL 3

Expert Comment

by:jjbyers
ID: 1489485
Have you tried checking all the characters in the string for a chr(13) and/or chr(10) then strip these out?

0
 

Expert Comment

by:T38Jet
ID: 1489486
obviously there's a carriage return after the E in "OFF LINE"

I tend to agree with jjbyers, but the problem with stripping out carriage returns and/or line feeds is which ones to strip out? (unless you have an exact number of bytes you ALWAYS receive for each record in the table)


0
 
LVL 3

Accepted Solution

by:
cognition earned 50 total points
ID: 1489487
Dim lni as integer
Dim lnPos as integer
For lni = 1 to Len(String)
    If Chr(Mid(lni, String, 1)) < 32 Then
        String = Mid(1, String, lni - 1) + " " + Mid(lni + 1, String, Len(String))
Next


0
 
LVL 3

Expert Comment

by:jjbyers
ID: 1489488
I would strip all CRLF's out. But you could also replace them with another character using the MID function within a loop.
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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

761 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