Solved

.NET Code Equivalent

Posted on 2011-03-17
8
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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 86

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

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month7 days, 11 hours left to enroll

632 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