RS232 Serial Communications Help

Hello Everyone,

I am currently creating a very small RS232 app that will perform a loop back and also check for a receiving computer by sending out an chr(5) & expecting a chr(6). If any characters are returned other than a chr(6), I need the character to display and fail the test. Because of the non printing status of chr(5) and chr(6) I can’t seem to get them to print correctly in my message box.

During my testing, when I send out a chr(5) and receive a chr(5), my message box shows the | character as being returned and fails the test (which it should). I would like it to show the character returned either in HEX (05) or the CHAR (ENQ). How do I get non printing character to show properly? I have attached my very simple code below which is in the serial1.DataAvailable sub. Thanks for any help with this!

dim r as String r = Serial1.ReadAll if r = chr(6) then MsgBox "<ACK> was received, PING Passed" Serial1.Flush elseif r = "LOOP" then MsgBox "LOOP Passed" Serial1.Flush else MsgBox r + " was received, should be <ACK>, PING Failed" Serial1.Flush end

MsgBox “0x” + hex(asc®) + " was received, should be , PING Failed"

Thank you so much Massimo, that worked great!!