Results 1 to 2 of 2

Thread: Serial data strings

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Location
    Illinois, USA
    Posts
    85

    Serial data strings

    I'm trying to emulate an old piece of DOS software with a newer VB
    version that I can modify.(while learning VB serial communications)

    So I have been looking at the serial output of the old software with a RS232
    monitor as in this sample: Like: 02 0D 0A 31 32 33 34 35 36 0D 0A(SOT CR LF 123456 CR LF). The code
    I've created produces "31 0D 0A 32 33 34 0D 0A 35 36". I'm trying to
    understand how to get the SOT CR LF in the correct places.

    I'm having trouble finding a simple explanation of doing this from scratch.
    Is this related to a Checksum routine possibly?
    Code:
    Private Sub cmdTest_Click()
    Dim OutTask$
    Dim Textstr$
    OutTask$ = "123456"
    TXString = OutTask$
    frmMain.MSComm1.PortOpen = True
    If Index = 0 Then
    frmMain.MSComm1.Output = TXString
    End If
        If frmMain.MSComm1.PortOpen = True Then
        frmMain.MSComm1.PortOpen = False
    End If
    End Sub
    Any suggestions appreciated
    Last edited by Aaron02; Mar 26th, 2007 at 02:58 PM. Reason: correction

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Serial data strings

    The serial data stream is the 11 characters SOT CR LF 123456 CR LF. Their hex values are 02 0D 0A 31 32 33 34 35 36 0D 0A.

    What you want (no need to use 2 string variables) is
    Code:
    TXString = Chr$(2) & vbCR & vbLF & "123456" & vbCR & vbLF
    frmMain.MSComm1.PortOpen = True
    If Index = 0 Then
    frmMain.MSComm1.Output = TXString
    End If
    No idea what Index is, since you didn't define it in the sub.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width