Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 423
Viewed: 2975
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Justification Of Text On A Printout

The code below shows four types of justification when printing.

left

right

centred

centred in a given column width, at a given position left in a given column width, at a given position

centred in a given column width, at a given postion It does not take into consideration:

1. text wider than the print area

2. optimization for speed

Will work with most font sizes except very large fonts.

Highlight all by clicking in box
<!---Declaration--->
none

Highlight All
<!---Code--->
Dim Txt As String
Dim ColPos As Long
Dim ColWidth As Long

Me.Cls

' 1. Left justify

Txt = "Left"

Me.CurrentX = 0

Me.Print Txt

' 2. Right justify on form

Txt = "Right"

Me.CurrentX = Me.ScaleWidth - Me.TextWidth(Txt)

Me.Print Txt

' 3. Centre on form

Txt = "Centred on form"

Me.CurrentX = (Me.ScaleWidth - Me.TextWidth(Txt)) 2

Me.Print Txt


'4. Right justify in a given width, at a given column.

Txt = "Right in col"

ColPos = Me.ScaleWidth 4

ColWidth = Me.ScaleWidth 4

Do Until Me.TextWidth(Txt) < ColWidth

' Make sure the text fits in the column.

Txt = Right$(Txt, Len(Txt) - 1)
Loop

Me.CurrentX = ColPos + (ColWidth - Me.TextWidth(Txt))

Me.Print Txt



'5. Left justify in a given width, at a given column.

Txt = "Left in col"

Do Until Me.TextWidth(Txt) < ColWidth

' Make sure the text fits in the column.

Txt = Left$(Txt, Len(Txt) - 1)

Loop

Me.CurrentX = ColPos

Me.Print Txt



' 6. Centred in a given width, at a given column.

Txt = "Centred in col"

Do Until Me.TextWidth(Txt) < ColWidth

' Make sure the text fits in the column.

Txt = Left$(Txt, Len(Txt) - 1)

Loop

Me.CurrentX = ColPos + (ColWidth - Me.TextWidth(Txt)) 2

Me.Print Txt



' Block the column to view justification of 4 and 5.

Me.Line (ColPos, 0)-(ColPos + ColWidth, Me.ScaleHeight - 10), , B;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions