Solved

.NET Code Equivalent

Posted on 2011-03-17
8
226 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

791 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