Discussion Locked

VB Dos Printing

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How to use Dos Printing in Visual Basic 6 and What is shell printing in VB 6?

2 replies

by jackofalltech

Sorry, we'll need a little more info. VB6 is a Windows program, why would you want to print in DOS? Also, please be more specific as to "shell printing".

Ralph

by kurrakiran

You can use "Draft 12cpi" font for printing which is fast like DOS

Else

(1) Write your output to a temp file, then shell to DOS and have DOS perform the print:

replace all Printer.Print commands with the below
you only need to open and close once.
If dir$("C:\tempfile.prn")>"" then
kill the existing file so it can be used
kill "C:\tempfile.prn"
end if
Open "C:\tempfile.prn" for append as #1
print #1, Stuff_That_Goes_To_The_Printer
Close #1

shell "cmd /c copy tempfile.prn prn"

(2) print directly to the printer from VB, rather than through a Windows driver

open "LPT1:" for output as #1
print #1, Stuff_That_Goes_To_The_Printer
close #1

If You want to print from a file?
If the file is already formatted, there could be a problem; if it's straight text, then it should go without problems:

dim vbFormFeed as string
vbFormFeed= chr$(12)

strFilename = "NameOfFileToPrint.txt"
Open strFilename for binary as #1
strFileContents = input$(lof(1), #1)
close #1

open "LPT1:" for output as #1
print #1, strFileContents; vbFormFeed;
close #1

This discussion is closed to new replies.