Solved

MSComm Control Blues

Posted on 1999-01-07
4
195 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

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…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

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

22 Experts available now in Live!

Get 1:1 Help Now