yymae
asked on
Urgent Help on VB6 chr$() to C#
Dear all,
I'm using VB6 need to convert to C# for printing. In VB6 I will send some printer command into the printer as below:-
Printer.Print "TESTING LINE 1"
Printer.Print "TESTING LINE 2"
Printer.Print Chr$(&H1C); "(L"; Chr$(66); Chr$(49);
Printer.Print Chr$(&H1D); "V"; Chr$(49);
Printer.Print Chr$(&H1C); "(L"; Chr$(67); Chr$(50);
In C# I'm writing a text file and open LPT1 to print some lines, the problem is how to convert those VB6 codes into C# ?
I've try using some sample code as below :-
writer.WriteLine ("TESTING LINE 1" + ((char) 13));
writer.WriteLine ("TESTING LINE 2" + ((char) 13));
writer.WriteLine( ((char)&H1C) + "(L" + ((char)66) + ((char)49));
writer.WriteLine( ((char)&H1D) + "V" + ((char)49));
writer.WriteLine( ((char)&H1C) + "(L" + ((char)66) + ((char)49));
But there are errors on '&H1C', '&H1D' on the above codes.
If I use VB6 to print it will print the "(L" character out when I'm using VB6 to print. How to resolve this as well ?
Please provide solutions and examples.
Thanks in advance
Cheers,
yymae
I'm using VB6 need to convert to C# for printing. In VB6 I will send some printer command into the printer as below:-
Printer.Print "TESTING LINE 1"
Printer.Print "TESTING LINE 2"
Printer.Print Chr$(&H1C); "(L"; Chr$(66); Chr$(49);
Printer.Print Chr$(&H1D); "V"; Chr$(49);
Printer.Print Chr$(&H1C); "(L"; Chr$(67); Chr$(50);
In C# I'm writing a text file and open LPT1 to print some lines, the problem is how to convert those VB6 codes into C# ?
I've try using some sample code as below :-
writer.WriteLine ("TESTING LINE 1" + ((char) 13));
writer.WriteLine ("TESTING LINE 2" + ((char) 13));
writer.WriteLine( ((char)&H1C) + "(L" + ((char)66) + ((char)49));
writer.WriteLine( ((char)&H1D) + "V" + ((char)49));
writer.WriteLine( ((char)&H1C) + "(L" + ((char)66) + ((char)49));
But there are errors on '&H1C', '&H1D' on the above codes.
If I use VB6 to print it will print the "(L" character out when I'm using VB6 to print. How to resolve this as well ?
Please provide solutions and examples.
Thanks in advance
Cheers,
yymae
Hello,
I wouldn't use the VisualBasic namespace, when C# can deal with this in it's own way.
Use
Console.WriteLine("Hello\x 41There");
This will produce the results
HelloAThere
Becuase hex 41='A'
\x is the escape sequence for hex
Smg.
I wouldn't use the VisualBasic namespace, when C# can deal with this in it's own way.
Use
Console.WriteLine("Hello\x
This will produce the results
HelloAThere
Becuase hex 41='A'
\x is the escape sequence for hex
Smg.
&H1C is a hex constant in basic. 0x1C would be the same hex constant in C#. Just replace &H with 0x.
writer.WriteLine("TESTING LINE 1");
writer.WriteLine("TESTING LINE 2");
writer.WriteLine(Chr(28) + "(L" + Chr(66) + Chr(49));
writer.WriteLine(Chr(29) + "V" + Chr(49));
writer.WriteLine(Chr(28) + "(L" + Chr(67) + Chr(50));
Bob
writer.WriteLine("TESTING LINE 2");
writer.WriteLine(Chr(28) + "(L" + Chr(66) + Chr(49));
writer.WriteLine(Chr(29) + "V" + Chr(49));
writer.WriteLine(Chr(28) + "(L" + Chr(67) + Chr(50));
Bob
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for accepting my answer, but why just a grade 'C' ?? was the answer missing something ?
Smg.
Smg.
Something like
If e.KeyChar = Microsoft.VisualBasic.ChrW
e.Handled = False
MsgBox("You pressed Enter.")
Exit Sub
End If
OR
Chr System.Char.GetNumericValu
Asc System.Char.Parse(String)