Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2004, 09:25 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default printer.print problem

Hello,

  I am printing tickets on my pre printed paper. Sorry, already i posted this problem a long back. But still not succeed. I am generating output and storing in a text file. When the print button is clicked, the data is read from the textfile and directs to the printer. I need to count the no of lines. so, i am copying to text file. This is my code...

Dim ret As Integer
Printer.PrintQuality = -1
Printer.FontName = "draft 10cpi"
Printer.FontBold = False
Printer.FontItalic = False
Printer.FontSize = 8

ret = MsgBox("Print(Y/N)", vbYesNo)

If ret = 6 Then printcontents


Dim objfile As Object, ln As Integer, ctext As Object
Set ctext = fso.CreateTextFile("c:\tempprint.txt", True)
ctext.WriteLine txtResult.Text
ctext.Close
Set ctext = Nothing
txtResult.Text = ""
Set objfile = fso.OpenTextFile("c:\tempprint.txt", ForReading, True)
ln = 1
Do While Not objfile.AtEndOfStream
    Printer.Print objfile.ReadLine()
    Printer.Print
    Printer.Print
    Printer.Print
    ln = ln + 3
Loop

Printer.EndDoc

My problem is, vertical spacing. According to the code, i am printing 3 lines in each iteration. After printing some lines the lines are moving up/down not in the proper way. Why is this happening? I am strucked at this place. Pls help me.

C the link how its printing. That is my pre printed ticket and the output printed from the code.

http://m.1asphost.com/tsimsha/images/ticket.jpg

Everytime i need to print minimum >500 lines(tickets). So i need to print faster. Thats why i am using printer.print with Draft 10cpi font. I need to print continuously until the tickets are over without any interruption or interaction.
Actually this is available in foxpro 2.5. There its printing correctly. I modified the application to VB. I have this problem.

Sorry for the long problem. But i want to explain clearly.
Finally, how can i set the equal vertical spacing. And the paper width also not sufficient in VB where as in foxpro the same width but no problem.

Thax in advance



 
Old December 13th, 2004, 03:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Before printing set the printer.currentY to the right value.
Find the distance between two rows and call that DY:

dim y as double
y = ...position of first row here...

loop:
printer.currentY = y
print.print "line of text"
y = y + dy

Marco
 
Old December 13th, 2004, 07:57 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

  Thanx for the reply. I tried that one but still same problem.

When i just print on the form the currentY value its showing 400,800,1200...
I incremented the same value for each ticket. But not succeed. What could be the problem. I tried all the ways. CurrentX works fine whereas currentY not.
When i print the same text file from DOS prompt its printing nice.

If i use shell("batchfile.bat")
any problem?? coz the printing time from start to end is about 30 mts(many tickets at a time).

Thanx

 
Old December 13th, 2004, 08:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

which printer are you using? print a test rectangle:

printer.scalemode = vbmillimeters
printer.line (20,20)-step(100,100),,B
printer.enddoc

and see if the size of the rectangle is correct

Marco
 
Old December 13th, 2004, 09:09 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
  I am using Epson LQ 580 on Win Me.

I triend u r suggession. I printed the line.
The horizontal position is correct (100 mm) and the vertical position is 99mm only.
What could be the problem.

Thanx in advance

 
Old December 13th, 2004, 10:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

do not ask me, ask Epson... the driver can be wrong, or the printer internal motor not calibrated... anyway this is not a software bug. Try another printer.

m.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Print using Dot Matrix printer in VB6.0 sabsait Pro VB 6 5 October 10th, 2009 03:17 PM
Dot Matrix Printer does not print crystal report alok_mca07 Crystal Reports 0 October 24th, 2007 11:32 AM
get the printer name chosen in print dialog deep_ocean Classic ASP Basics 0 March 14th, 2007 10:27 AM
Access to print PDF file to default printer Dkline Access VBA 0 July 7th, 2004 03:24 PM
VB Printer.print command Hiddenattractor Java GUI 3 December 30th, 2003 09:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.