none
Send data to customer display via RS232 is almost working RRS feed

  • Question

  • Hi everyone,

    I have a test form with 2 buttons named "First" and "Second" below are the code I have put, but I try to clear the display by sending a print command but it does not work, I am sure someone will know what I have to do :)

    Thanks

    Claude from Quebec, Canada

    Private Sub First_Click()
    Open "COM3" For Output As #1
    Print #1, Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20);
    Close #1
    Open "COM3" For Output As #1
    Print #1, Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20);
    Print #1, "Lise"
    Close #1
    Open "COM3" For Output As #1
    Print #1, Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20);
    Print #1, "Laframboise"
    Close #1
    
    End Sub
    
    Private Sub Second_Click()
    Open "COM3" For Output As #1
    Print #1, Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20);
    Close #1
    Open "COM3" For Output As #2
    Print #2, "Claude"
    Close #2
    Open "COM3" For Output As #3
    Print #3, "Larocque"
    Close #3
    
    End Sub
    

    Friday, December 20, 2019 10:34 PM

Answers

  • Or, instead of sending  Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); … to clear the line, use  Chr$(20) & Chr$(20) & Chr$(20) & Chr$(20) & Chr$(20) & …

    Hi Claude,

    "20" is the Hex-value voor the space-character. and not the decimal value.

    So you can try:  Chr(32) & Chr(32) & … etc.

    Imb.

    Saturday, December 21, 2019 12:06 PM

All replies

  • Hi Claude,

    Long time ago!

    What happens if you pad the tekst with spaces, so send "Claude              " instead of just "Claude"?

    Or, instead of sending  Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); … to clear the line, use  Chr$(20) & Chr$(20) & Chr$(20) & Chr$(20) & Chr$(20) & …?

    Imb. 

    Saturday, December 21, 2019 8:58 AM
  • Hi Imb,

    You're right didn't ask for help for a while, I tried the Chr$(20) & … and no response at all for the display. For the padding with spaces, it might be possible but sometimes the products have 6 letters, sometimes 10 and sometimes 20. The first line is products that comes from a table named tblSend2VFDTemp and with coding, I change the products in that table each time a user select one. On the second line it is the price, it could be 0,99 $ or 99,99 $ or 999,99 and in some of customers that sells cars 99999,99 so I am not sure if padding is good.

    Thanks

    Claude

    Saturday, December 21, 2019 11:08 AM
  • You're right didn't ask for help for a while, I tried the Chr$(20) & … and no response at all for the display. For the padding with spaces, it might be possible but sometimes the products have 6 letters, sometimes 10 and sometimes 20. The first line is products that comes from a table named tblSend2VFDTemp and with coding, I change the products in that table each time a user select one. On the second line it is the price, it could be 0,99 $ or 99,99 $ or 999,99 and in some of customers that sells cars 99999,99 so I am not sure if padding is good.

    Hi Claude,

    No problem! You can use something like:   Left(your_text & String(20," "),20)  to pad to 20 characters.

    Imb.

    Saturday, December 21, 2019 11:43 AM
  • Or, instead of sending  Chr$(20); Chr$(20); Chr$(20); Chr$(20); Chr$(20); … to clear the line, use  Chr$(20) & Chr$(20) & Chr$(20) & Chr$(20) & Chr$(20) & …

    Hi Claude,

    "20" is the Hex-value voor the space-character. and not the decimal value.

    So you can try:  Chr(32) & Chr(32) & … etc.

    Imb.

    Saturday, December 21, 2019 12:06 PM
  • Bingo,

    I knew that you can help, by replacing (20) by (32) everything went well. I did also test by changing data into my temporary table and it works perfect.

    Thanks again and I wish you wonderful Holidays!

    Claude

    In case it can help someone else here is the working code:

    Private Sub First_Click()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim Line1 As String
    Dim Line2 As String
    
    Set dbs = CurrentDb
    Set rst = CurrentDb.OpenRecordset("tblSend2VFDTemp")
    
    Line1 = rst![Nom du produit]
    Line2 = rst![Prix unitaire]
    
    Open "COM3" For Output As #1
    Print #1, Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32); Chr$(32);
    Close #1
    
    Open "COM3" For Output As #1
    Print #1, Line2 & " $"
    Close #1
    Open "COM3" For Output As #1
    Print #1, Line1
    Close #1
    
        rst.Close
        dbs.Close
        Set rst = Nothing
        Set dbs = Nothing
    
    End Sub

    Saturday, December 21, 2019 12:40 PM