Align printed text output 
Author Message
 Align printed text output

I am using VB4 Professional Edition, When I print the data I need I am
unable to get the text to align properly.

Here is the code I'm using

Private Sub cmdPReport_Click()
Dim db As Database, rs As Recordset
Dim beginpage, endpage, numbcopy, ic
Dim printhead As String
printhead =  _
"NAME          LOGINS     TOTAL LOGIN TIME          AVG LENGTH    "
Set db = DBEngine.Workspaces(0).OpenDatabase("C:\project\billing.mdb")
Set rs = db.OpenRecordset(datData1.RecordSource, dbOpenSnapshot)
If datData1.RecordSource = "SELECT * From User order by [NAME2] asc" _
      CommonDialog1.CancelError = True
      beginpage = CommonDialog1.FromPage
      endpage = CommonDialog1.ToPage
      numbcopy = CommonDialog1.Copies
      For ic = 0 To numcopy
      Printer.Print printhead
        While Not rs.EOF
           Printer.Print rs!NAME2 &  rs!LOGINS & rs!TOTAL_LOGIN_TIME _

              & rs!AVG_LENGTH
    Exit Sub
ElseIf datData1.RecordSource = "select * from Modem" Then

End Sub

I have tried putting spaces in between the feilds I am loading in the
'Printer.Print' line, but the text will not align properly.

Here is a sample:

acampton          3       6 Hours 11 Min          2 Hours 3.666667Min.
bcoffey          30       13 Hours 19 Min       0 Hours 0.6333333 Min.
bduncan          2       0 Hours 46 Min               0 Hours 23 Min.
bnewman          7       1 Hours 1 Min          0 Hours 0.1428571 Min.
bpatton          16       2 Hours 6 Min            0 Hours 0.375 Min.
bsharp          30       30 Hours 44 Min         1 Hours 1.466667 Min.
bwilkin          10       3 Hours 58 Min              0 Hours 5.8 Min.

Crystal reports is not an option in this application.  Does anybody
have any suggestions as to how I can get this text to align like
this(or close to it):

acampton    3              6 Hours 11 Min            2 Hours 3.67 Min.
bcoffey        30           13 Hours 19 Min           0 Hours 0.6 Min.
bduncan      2             0 Hours 46 Min             0 Hours 23 Min.
bnewman     7            1 Hours 1 Min                0 Hours 0.1 Min.
bpatton       16           2 Hours 6 Min                0 Hours0.3Min.
bsharp        30          30 Hours 44 Min             1 Hours 1.4 Min.
bwilkin        10           3 Hours 58 Min             0 Hours 5.8Min.

Thanks in advance


Sun, 09 Jan 2000 03:00:00 GMT
 Align printed text output

You really need to specify where the text goes. Use the Printer.CurrentX
and Printer.CurrentY commands.
Also break up your routine in pieces, ie have one to print just the header,
one for footer, and one for body.
If you monitor the currentY you will know when to jump to the next page and
start a new one. You really need
to set up code to get page size info from the printer driver, so that you
can set constants for where the top
margin starts and where the end of the page is, as well as the side

Example:  This assumes that the mode is in inches.

'Start data loop
 While Not rs.EOF
'For each line to print.
printer.currentX=1    'ie inches in this example
printer.print A$;               'notice the semicolon to prevent a line feed.
'next value etc
printer.currentX=3      'ie it prints a 3inches over.
'next print statement.
'next values etc
'on the last value on the line print it without the semicolon this will
force CurrentY to next position
'At the end of each line you print do a check on CurrentY ..... Example
If Printer.CurrentY=>10 Then         'getting close to bottom of page.
'interupt printing
Call DoFooter           'Would print a page number etc.
Call DoHeader    'resets currentY to header and prints header
Printer.CurrentY=2    'Set first line to print at 2 inches from top.
end if

Your DoHeader and DoFooter would locate each coloum header and printit to
that X position.
Don't try to print the whole header on one line. And remember the semicolon
to prevent line feeds.

> I am using VB4 Professional Edition, When I print the data I need I am
> unable to get the text to align properly.

Tue, 11 Jan 2000 03:00:00 GMT
 [ 2 post ] 

 Relevant Pages 

1. Aligning printed text output

2. Align printed text output

3. RE Align printed text output

4. VFP3.0: Ramdom shifting of aligned fields in Report output

5. How to direct output of PRINT to a text file

6. How can I align fields in columns using printer.print (DAO)

7. Help on aligning pre-printed forms with NEC Pinwriter P2000

8. Tabs not Aligning when Printed

9. Print aligning

10. Aligning Field Text with ObjectPAL

11. Aligning text in a multiline textbox

12. need to align a single text field with a repeating Number field

Powered by phpBB® Forum Software