Solved

MSComm Control Blues

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

747 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

11 Experts available now in Live!

Get 1:1 Help Now