Aligning printed text output 
Author Message
 Aligning 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)
rs.MoveFirst
If datData1.RecordSource = "SELECT * From User order by [NAME2] asc" _
Then
      CommonDialog1.CancelError = True
      CommonDialog1.ShowPrinter
      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
           rs.MoveNext
       Wend
    Printer.EndDoc
       Next
    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:

NAME          LOGINS     TOTAL LOGIN TIME          AVG LENGTH    
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):

NAME         LOGINS   TOTAL LOGIN TIME   AVG LENGTH    
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

John



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

The easiest way I've found to align text is to used a fixed width font.
Courier comes standard with Windows and is a fixed width font. I don't care
for that font so I use Letter Gothic. But it may be the only one you have
and it works well.



Thu, 13 Jan 2000 03:00:00 GMT
 Aligning printed text output

Quote:

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

You are using a proportional font. (See  the entry on "Textwidth" in
the help file for more details).

Change the printer font to a FIXED width like Courier.

problem solved.

Jeff.



Fri, 14 Jan 2000 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Align printed text output

2. RE Align printed text output

3. 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. Help on aligning pre-printed forms with NEC Pinwriter P2000

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

8. Tabs not Aligning when Printed

9. Print aligning

10. Align field with text

11. Aligning text in a multiline textbox

12. Paradox for Windows: report text align


 
Powered by phpBB® Forum Software