19 Sep 03 3:07
Firstly, are you sure you should do it direct from VB without using a report writer?
But if you do want to do it straight from VB, here's some thoughts. You'll need to learn the PCL commands first.... somewhere in this board there's a url for electronic copies of the PCL manuals if you've not got them already. Once you figure out the commands you need, you need to create output strings in your VB code, to send to the printer. The escape code, which is part of each PCL command is Ascii character 27, so you need a Chr(27) in the strings at the appropriate point.
But here's the problem.... usually, when you use the printer object in VB to print with, it puts MORE PCL code round what you send (or PostScript, depending on the driver you use) and that messes the whole thing up.
So one of my colleagues found a reference at MicroSoft on how to do what they call Raw Printng, which is direct to the printer not thru' the driver. We experimented with it and it does work. Here's the url: http://support.microsoft.com/support/kb/articles/Q154/0/78.asp
In the VB code, you will see they create a string called sWrittenData which they send to the printer. If for example you make that string something like....
sWrittenData = Chr(27) & "(s4101T"
that would set the typeface to CG Times which is typeface number 4101. (The typeface command is esc(s#T where the # is the typeface number.)
You need to construct a whole lot of strings like that, each one with the commands to do what you want, and the text you want to print, of course.
My time is GMT+2