Solved

.NET Code Equivalent

Posted on 2011-03-17
8
217 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

706 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

18 Experts available now in Live!

Get 1:1 Help Now