Control codes - how to type them into a programme

Here I am struggling to get my PC to talk to an electronic sign board (junk from an old callcentre that will now do service as a score board at the school I teach at).

Background:

I am able to have the sign working using it's own software, so it does function. Unfortunately this is a SCO UNIX box that runs a mass of other things, with the sign being a miniscule part of the functions. This footpring is too big!

Problem:

I have the protocol for initialising it, and was able to capture some of the control codes via hyperterminal. The code I captured is <Esc>, also known as hex 1B or 0x1b. the captured character looks like a left facing arrow (here it looks like a little block.... ), but I am unable to get VB to allow me to type the neccessary characters. How do you insert those characters They are unavailable in Character Map and there doesn't seem to be anywhere that allows you to insert them. The part pasted below does what I expect it to do with the sign, but until I am able to insert the other codes (eg: 0x1a) I am at a loss.

Sample code:

Private Sub cmd_reset_Click()
' Software Reset for 7415 V1 board
' Reset/initialise string for single line, works!!! Inverted commas ("") needed.
MSComm1.Output = " @A000000A @A000001A @A000002A @A000003A @A000004A @A000005A @A000006A @A000007A"
' 2 Line initial...... What is 0x1A Got 0x1B =
' MSComm1.Output = " @C I000000A 0x1A S1 C @D"
End Sub

Obviously the comments are there to help me think!

Any help would be greatly apreciated.

Poida




Answer this question

Control codes - how to type them into a programme

  • th0

    escape is ascii code 27 ( or 0x1B in hexidecimal)

    here's a function:

  • HY

    You can download VB Express (2005) and use it for free for year on Microsoft.com

  • Jetcity73

    are you using vb6

  • alex express

    Thank you for your reply, but due to my inexperience in the VB 6 programming environment (having done my Masters in Comp. Sci. using Turbo Pascal way back in 1989...) I am unable to make head or tail of the supplied code. My interpretation of what I need to do to make the code run results in multiple different errors when I try to run it. Usually a compile error "User-defined type not defined".

    I think I did not explain the problem clearly enough, and have found, while following another resolution path an almost suitable way to enter the codes I need into the program. Using wordPad I type in the Hex value (eg 1b) followed by <alt>X and it is converted to it's single character that I can then copy and paste into the program. The only value I cannot use is 0x0A as it is the carage return character, so when I paste it into the txt_message.Text = txt_message.Text & " (the resulting character)" it moves to the next line, and quite obviously causes that line to cause an error.

    As an aside, I am using buttons to insert these codes, but as you can see from the sample above I have not yet found how to insert the character into a line in a text box at the position of the cursor. Is there an easy way of doing this

    Pete



  • Control codes - how to type them into a programme