Solved

.NET Code Equivalent

Posted on 2011-03-17
8
227 Views
Last Modified: 2012-06-21
I have an old program I am updating.  It uses a key sequence for function keys.  

Chr$(27) + "OR" '

What would be the .NET equivalent?

I tried the following without success.

Chr(27) + "OR"
Chrw(27) + "OR"
0
Comment
Question by:Kevin_Foley
8 Comments
 
LVL 8

Accepted Solution

by:
pdd1lan earned 100 total points
ID: 35156461
0
 
LVL 4

Expert Comment

by:Loftbug
ID: 35156495
Hi Kevin,

It sounds like you wish to write out ASCII characters.

In C# we do it as follows:
string mystring = "\24" + "OR";

VB.Net doesnt support this out of the box, but there is a static method which allows VB.Net users to use the same syntax.

Try the following:
Dim mystring as String = Regex.Unescape(”Ashish Mohta\n Phone\tMynumber”)

Best,

 L
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 100 total points
ID: 35156507
Try:
        Dim c As Char
        c = Char.ConvertFromUtf32(27)

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 200 total points
ID: 35157078
Humm... Chr(27) + "OR" should have worked.

Do you have a reference to the Microsoft.VisualBasic namespace?

Otherwise, what error do you get?
0
 

Author Comment

by:Kevin_Foley
ID: 35157312
This command gets sent to an emulator.  It is not generating an error but the emulator is not recognizing it, so I'm trying to figure out why.
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 100 total points
ID: 35157338
Do you have other similar "key sequences" that are working and this is the only one that doesn't?

...or are you having communication problems in general?

Give us more details and context.  =)
0
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 200 total points
ID: 35157541
I think VB strings have single-byte characters (ASCII), while VB.NET strings have double-byte characters (UNICODE).  So, you may have to do some conversion before sending the command to the emulator.

Here is a sample code to convert from UNICODE to ASCII:
Dim cmd As String

' ... build cmd ...

' Perform the conversion from one encoding to the other.
Dim asciiBytes As Byte() = Encoding.Convert(Encoding.Unicode, Encoding.ASCII, Encoding.Unicode.GetBytes(cmd))

' ... send asciiBytes to emulator ...

Open in new window

0
 

Author Closing Comment

by:Kevin_Foley
ID: 35182532
Thanks for all the input.  At the end of the day, there was nothing wrong with using

chr(27) + "OR" as I had it coded.  

The problem turned out to be that the emulation type was getting hijacked and reset from vt100 to vt320.  I fixed this and the code worked perfectly.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

680 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