VB6 to VB.NET code conversion string problem

Viewed 122

I had a program with code conversion VB6 (on WinXP 32bit) which sends command to RS232 radio modem. I rewrite the code into VB.NET (WinX 64bit) but the output string to serial port is different. For example:

VB6 code:

Chr$(193)

Output is:

VB6output

VB.NET code:

Convert.ToChar(193)

Output is:

VB.Netoutput

I think this has something to do with character tables but cannot find any solution Thanks for any info

1 Answers

According to this link from Microsoft, Convert.toChar(...) does this:

Converts the value of the specified object to a Unicode character.

My guess is you're getting a unicode, since instead of C1, you're getting C3 81 (Unicode can take 1-4 bytes per char). Perhaps something like this answer would help:

((char)0x00C1).ToString();

Related