Sending raw text to a printer
I'm trying to write a program which reads in a plain text file, adds a line to the top of it and then sends it to the printer. This line is a set of controls which the printer knows what to do with and it sets up the layout etc. of the paper.
First of all, the file is being produced no problems and comes out exactly right. I have already sucessfully completed a Java version which runs and works perfectly, and they create identical files so I know that that's not the problem... so it must be somewhere in the sending.
So, starting from scratch, how do you print in VB given that you have a filename "myFilename".
Incidentally, the line that I have to add is as follows (escape is char27):
escape + "E" + escape + "&l1H" + escape + "&l26a1O" + escape + "9" + escape + "&l0l6d12e36F" + escape + "(s0p10H" + escape + "&a3L"
Re: Sending raw text to a printer
VB Code:
Open "C:\PRN" For Output As #1
Print Chr(27) & "E" & Chr(27) & "&l1H" & Chr(27) '& ....and so on...
but you can not use a printer with usb port or network printer by using these codes...i dont know otherwise how to send these to the printer....
just give a try
VB Code:
Printer.Print Chr(27) & "E" & Chr(27) & "&l1H" & Chr(27) '& ....and so on....
Re: Sending raw text to a printer
basically to print from a file
VB Code:
FileNum = FreeFile
Open myFileName For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, OneLine
Printer.Print OneLine
Loop
Close (FileNum)
Re: Sending raw text to a printer
printer.print doesn't work. I'll probably shoot myself if I've just missed an import or something.
Re: Sending raw text to a printer
Quote:
Originally Posted by Insaneogram
printer.print doesn't work
are you getting any error?
Re: Sending raw text to a printer
There's no printer class. I've looked through the object library. Is it a .net thing?
Re: Sending raw text to a printer
no, that is vb 6.0 only...and you can open the printer object without any reference or components...
Re: Sending raw text to a printer
Ok well what it's telling me is that Printer is not declared
Re: Sending raw text to a printer
unbelivable....just open a new project and in the code window write
VB Code:
Printer.Print "Hai"
Printer.EndDoc
and see what happens when you execute it...
Re: Sending raw text to a printer
Re: Sending raw text to a printer
could you find it in the object browser, by pressing F2 key you can get the object browser and type printer in the search box and hit enter, see if you find any class there in the name of printer....
Re: Sending raw text to a printer
No, not in the object browser. I'm using MS VB 2005 Express edition from a Microsoft Partner pack if that helps at all.
The other solution is to find a native compiler for Java that can handle printers, since my Java program worked fine on the virtual machine. This is my first time using VB.
Re: Sending raw text to a printer
sorry no idea, i never used vb 2005 express
Re: Sending raw text to a printer
Where can I get a version that will allow printer.print?
Re: Sending raw text to a printer
vb 2005 express is really vb dot net, so while someone here may know and be able to answer, you are really in the wrong forum and more likely to get an answer in the vb.net forum
i have no idea how to print in dot net
pete
Re: Sending raw text to a printer
Using a PRINTER object with an ESCAPE sequence is a losing battle. The print driver gets in the way of ESCAPE sequences.
You need to have that printer accessed as a file or maybe with some kind of "generic text" print driver (they are available - I've seen my customers use them).
Re: Sending raw text to a printer
Quote:
Originally Posted by szlamany
You need to have that printer accessed as a file or maybe with some kind of "generic text" print driver (they are available - I've seen my customers use them).
Windows has a Generic printer "manufacturer". One of those printers is a "Generic Text Only" printer. Just install a new printer, choosing Generic as the manufacturer and Generic Text Only as the model.
Re: Sending raw text to a printer
That's exactly what I meant - thanks!
Re: Sending raw text to a printer
Re: Sending raw text to a printer
you dont need to change the version of your vb, just post your query in vb.net forum to get the answer..
Re: Sending raw text to a printer
Re: Sending raw text to a printer
This is seriously giving me the ****s now
Re: Sending raw text to a printer
please see the following thread:
http://www.vbforums.com/showthread.php?t=401045
all is there.
all the best