Solved

.NET Code Equivalent

Posted on 2011-03-17
8
221 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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now