Solved

How to print with right-to-left aligment

Posted on 2001-07-06
8
903 Views
Last Modified: 2007-11-27
How can I print with right-to-left aligment?
I need to print some senteces with an exact right aligment.

Help me please
0
Comment
Question by:macob
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:ScottNero
ID: 6260967
Print where? On the screen? On a printer? From where? More details required.
0
 
LVL 4

Expert Comment

by:mcoop
ID: 6261024
The most obvious method assuming that you are not using a label control etc...

...is to set the font/size etc for the target print context, then use the .TextWidth(<yourText>) function against that context to find the actual width of <yourText>.

Then - position the target's print cursor with the .CurrentX = <yourRHlimit> - <the width of the text>

then finally .Print <yourText>

Of course you also have to manage the .CurrentY property, and calc/print any other lines that will be positioned above/below.
0
 
LVL 1

Expert Comment

by:ahmadpj
ID: 6261225
If you are using a non-bidirectional windows, mcoop suggestion is good, but if you are using a bidirectional windows (like arabic or hebrew) you can set your printer RightToLeft to True:
Printer.RightToLeft = True
then, the 0,0 point will be in the TopRight of the paper, and your text will be printed with right alignment...
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:macob
ID: 6261596
I already try using Printer.RightToLeft = True and .TextWidth() but they didnt work.
Could somebody send me an example that works?

Thanks

0
 
LVL 4

Accepted Solution

by:
mcoop earned 110 total points
ID: 6261688
For the money....

Private Sub Form_Load()
 
  Dim textLine(3) As String
 
  textLine(0) = "Welcome to the world"
  textLine(1) = "of right-aligned"
  textLine(2) = "printing"
  textLine(3) = "$ 123.45"
 
  ' (we could use the 'With Printer' block here
  ' - but I wanted to make everything obvious)
 
  Printer.ScaleMode = vbMillimeters ' use whatever you like
  Printer.Font.Name = "Arial"
  Printer.Font.Size = 12
 
  rightMargin = 20 ' your preferred distance from the right edge of the page
  rightlimit = Printer.ScaleWidth - rightMargin  '
 
  Printer.CurrentY = 100  ' approx 4 inches fro top of page
 
  For lNum = 0 To 3
    tWidth = Printer.TextWidth(textLine(lNum))
    Printer.CurrentX = rightlimit - tWidth
    Printer.Print textLine(lNum)  ' no semicolon - will use font's line spacing
  Next
 
  Printer.EndDoc

End Sub
0
 

Author Comment

by:macob
ID: 6261725
Everything works! what means :

' no semicolon - will use font's line spacing

?
0
 
LVL 4

Expert Comment

by:mcoop
ID: 6261823

if you put a semicolon (or comma) after the print statement, the next print statement will execute on the same line as that with the semicolon. (see the Print statement help)

In that case, you would have to manage the vertical placement manually (which you may want to do... for oddball line spacing etc.)

Otherwise, making sure that the print statement ends clean (no semi or comma etc), will ensure that the normal 'line feed' will be inserted as usual following your pinted text - thus you only need to manage the horizontal positioning with .currentX

0
 

Author Comment

by:macob
ID: 6261858
thanks for the help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question