fongye

How to convert to VB6 code below to C#.NET

The Printer Object in VB6 is replace with the printdocument object in .net version.

the VB6 code is sending the escape code to epson printer TM-U300A.

When i try to use the same method to sending the escape code to the same printer by define the control font and font size sending the same string to the printer, but it's not working to the printer to open the drawer like what it done in the VB6 code below.

can anyone tell me what wrong with it

Printer.Print
If Paper <> "0" Then
'Select paper source. If "Paper" is 0, then Nothing is printed.
Printer.Font.Size = 10
Printer.Font.Name = "control"
Printer.Print Paper
End If

Printer.Font.Size = 15
Printer.Font.Name = "Times New Roman"
Printer.Print message(0)
Printer.Font.Size = 15
Printer.Font.Name = "Times New Roman"
Printer.Print message(1)
Printer.Font.Size = 10
Printer.Font.Name = "control"
Printer.Print dcontrol
Printer.EndDoc

private void button1_Click(object sender, EventArgs e)

{

printFont = new Font("control", 10);

PrintDocument pd = new PrintDocument();

pd.PrintPage += new PrintPageEventHandler

(this.pd_PrintPage);

pd.Print();

}

private void pd_PrintPage(object sender, PrintPageEventArgs ev)

{

ev.Graphics.DrawString("A", new Font("control", 10), Brushes.Black, 10, 10);

}



Re: Visual C# General Convert VB6 to C#.NEt Code for POS printer

Ji Cheng Wang - MSFT

Hi fongye,

I'm not familiar with the printing in VB6. If you would like to print a text in C#, I suggest you to check out this article - http://www.codeproject.com/csharp/multipadprintdocument.asp for reference. Besides, here is a tool to convert VB.NET source codes to C# for you - http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx

Hope this helps,

Regards,

This response contains links reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.
Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.






Re: Visual C# General Convert VB6 to C#.NEt Code for POS printer

Isaiyavan Babu Karan

Hi if you can somehow convert your VB 6 code to VB.Net code, you can use http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx to convert VB.Net to CS code.