Urgent Help on converting vb6 chr$() to C#

G

Guest

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));

But there are errors on the above codes. Please provide solutions and
examples.

Thanks in advance


Cheers,
Mae
 
J

Jon Skeet [C# MVP]

Mae Lim said:
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));

But there are errors on the above codes. Please provide solutions and
examples.

Well, the simplest way to get character 13 is just "\r". For hex, just
change &H to 0x, so &H1C is 0x1c, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top