|
-
Jul 24th, 2006, 11:44 PM
#1
Thread Starter
Junior Member
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"
-
Jul 24th, 2006, 11:56 PM
#2
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....
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 24th, 2006, 11:58 PM
#3
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)
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 25th, 2006, 12:00 AM
#4
Thread Starter
Junior Member
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.
-
Jul 25th, 2006, 12:03 AM
#5
Re: Sending raw text to a printer
 Originally Posted by Insaneogram
printer.print doesn't work
are you getting any error?
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 25th, 2006, 12:07 AM
#6
Thread Starter
Junior Member
Re: Sending raw text to a printer
There's no printer class. I've looked through the object library. Is it a .net thing?
-
Jul 25th, 2006, 12:11 AM
#7
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...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 25th, 2006, 12:12 AM
#8
Thread Starter
Junior Member
Re: Sending raw text to a printer
Ok well what it's telling me is that Printer is not declared
-
Jul 25th, 2006, 12:28 AM
#9
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...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 25th, 2006, 12:31 AM
#10
Thread Starter
Junior Member
Re: Sending raw text to a printer
-
Jul 25th, 2006, 12:33 AM
#11
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....
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 25th, 2006, 12:41 AM
#12
Thread Starter
Junior Member
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.
-
Jul 25th, 2006, 01:22 AM
#13
Re: Sending raw text to a printer
sorry no idea, i never used vb 2005 express
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 25th, 2006, 01:29 AM
#14
Thread Starter
Junior Member
Re: Sending raw text to a printer
Where can I get a version that will allow printer.print?
-
Jul 25th, 2006, 05:09 AM
#15
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
-
Jul 25th, 2006, 07:39 AM
#16
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).
-
Jul 25th, 2006, 10:13 AM
#17
Re: Sending raw text to a printer
 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.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jul 25th, 2006, 10:16 AM
#18
Re: Sending raw text to a printer
That's exactly what I meant - thanks!
-
Jul 25th, 2006, 07:55 PM
#19
Thread Starter
Junior Member
Re: Sending raw text to a printer
-
Jul 26th, 2006, 12:12 AM
#20
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..
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 26th, 2006, 12:45 AM
#21
Thread Starter
Junior Member
Re: Sending raw text to a printer
-
Jul 27th, 2006, 07:41 PM
#22
Thread Starter
Junior Member
Re: Sending raw text to a printer
This is seriously giving me the ****s now
-
Sep 15th, 2006, 04:46 AM
#23
Addicted Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|