-1

ASCII character for 0 is differenct in vb6.0 compared to c#. I have converted vb6.0 code to c# where i need to send hex data as characters in port communication.

C# - Comm1.Write('/0').ToString() --> gives char as /0.

VB6.0 - mscomm.Output(char(0)) ---> give '' space .

Similarly for 7 c#--> gives '/a' as character

vb 6.0 --> gives as . black dot

Anyone can suggest me why this difference occurs in both as ASCII coding is same

Alok Sharma
  • 85
  • 1
  • 5
  • What is char in vb6, I thought the keywords were chr and chrw in vb6. Is char a custom function in your vb6 code? If so show that code. – Ryan Mann Sep 01 '15 at 14:35
  • `'/0' ` ? Some code that is close to compilable would help with understanding the problem. – Alexei Levenkov Sep 01 '15 at 14:38
  • 1
    Try `(char)0` or `(char)a`, you are not comparing apples to apples. – Ron Beyer Sep 01 '15 at 14:39
  • `vbNullChar` is a prefined constant you should be using. But your C# snippet sends a "/" and then a "0" so of course that's the result you would get. As hinted at above you probably meant to use `\0` the escaped NUL character in high-obscurity languages like C#. – Bob77 Sep 04 '15 at 22:51

1 Answers1

-1

VB6 codes everything in ANSI, this is the reason why you're getting question marks and unexpected characters.

silkfire
  • 24,585
  • 15
  • 82
  • 105
  • Ya , yup u r right so i used Microsoft.VisualBasic.Strings.Chr for converstion in c# .But from 0 to 10 decimal value it gives me difference between both c# and vb 6.0 . After 10 they give me same char output. Can u show me an example of similar converstion in c# and vb 6.0 for 0 decimal or 7 decimal . Thanks in advance – Alok Sharma Sep 01 '15 at 14:41