Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MSComm Control Blues

Posted on 1999-01-07
4
Medium Priority
?
202 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 150 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

963 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