Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print to a printer from a text file

Status
Not open for further replies.

starmistress

IS-IT--Management
Apr 16, 2001
32
US
I need suggestions on printing a file. This would be the last step of the program. the preceding steps are to import a text file into a database, manipulate the data, write some of the data to a text file, then print it. It's the printing I am struggling with. There could be anywhere from 10 to 200 records printed. 36 will fit on each page. the pages need to be numbered (I have that part figured out)and there needs to be a header row. Each record is approx. 85 characters wide, so I am printing landscape. I tried to open the whole file, then split it into an array, then loop through the array and print each line. Is there a limit as to how much info can be in an array? In theory, the code would need to handle 200 lines of 84 characters each.

Any suggestions would be greatly appreciated.
 

I would think that you should have no problems with 200 lines at 84 characters, but I would suggest since this is a strait read/print that you could do something like...

[tt]
Public Sub PrintFile(PathFileName As String)

Dim FNumb As Integer, LineCount As Integer, S As String, PgCnt As Integer

FNumb = FreeFile

Open PathFileName For Input As #FNumb

Do While Not Eof(#FNumb)
If LineCount = 0 Then
Call ProcessHeader
ElseIf LineCount = 36 Then
PgCnt = PgCnt + 1
Call ProcessPageNumber(PgCnt)
LineCount = 0
End If
Input #FNumb, S
Printer.Print s
LineCount = LineCount + 1
Loop

Close #FNumb

End Sub

Public Sub ProcessHeader()
'print your header here
End Sub

Public Sub ProcessPageNumber(PageNumber As Integer)
'do your formatting here
End Sub
[/tt]

or something like that

Good Luck

 

hmmm, couple of corrections

That should be Line Input #FNumb, S and in processpagenumber you should have Printer.NewPage

Good Luck

 
of course. at the end of a long day, sometimes it's tough to figure out the simplest way to accomplish a task. Thanks for the input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top