[RESOLVED] Printer.RightToLeft Not Working
I am having a problem getting Printer.RightToLeft to work. The part of my form that does this is:
Printer.RightToLeft = True
Printer.FontBold = False
' *** PRINT THE COLUMN TEXT ***
y = 0.5 - 0.2085
For i = 1 To 36
y = y + 0.2083
Printer.CurrentX = 3.15
Printer.CurrentY = y
Select Case i
Case 11, 13, 14, 15, 18, 19, 23, 24, 26, 27, 29, 30, 31, 33, 34
Printer.FontSize = 8
Printer.CurrentY = y + 0.025
Case Else
Printer.FontSize = 10
End Select
Printer.Print ColumnText(i)
Next i
When I run the program the text is printed at the correct starting point but the printing is left-to-right.
I am using XP and VB6.0
Last year I wrote a similar form and the righttoleft worked then but I can't (a) remember how I did it or (b) find the old program.
You help is appreciated :)
Re: Printer.RightToLeft Not Working
RightToLeft property is designed to handle Right-To-Left Languages (Hebrew, Arabic, etc) so I think it depends on your locale.
Is that what you need to do or do you simply need to right align some text?
Re: Printer.RightToLeft Not Working
I would like to right align some English text.
Re: Printer.RightToLeft Not Working
There are various technics to accomplish that including padding with spaces, RSet, Tabs...
Here is a quick sample that uses fixed length string and RSet statement:
Code:
Private Sub Command1_Click()
Dim strText1 As String * 10
Dim strText2 As String * 20
Dim strText3 As String * 15
Dim strLine As String
RSet strText1 = "abc"
RSet strText2 = "1234"
RSet strText3 = "abc123"
strLine = strText1 & strText2 & strText3
Me.Print strLine
End Sub
Re: Printer.RightToLeft Not Working
As Rhino has mentioned, padding blanks is an alternative that works, but the printer font should be non-proportional, such as Courier or Courier New. Here's some sample code using the Format$() function to pad the leading blanks:
Code:
Dim MyLines(3), MaxLine As Integer
Private Sub Command1_Click()
For I = 0 To 3
Printer.Print Format$(MyLines(I), String$(MaxLine, "@"))
Next
Printer.EndDoc
End Sub
Private Sub Form_Load()
MyLines(0) = "Hello."
MyLines(1) = "I am going to"
MyLines(2) = "print these four lines"
MyLines(3) = "right justified after you press the command button."
For I = 0 To 3
If MaxLine < Len(MyLines(I)) Then MaxLine = Len(MyLines(I))
Next
Printer.FontName = "Courier New"
End Sub
Re: Printer.RightToLeft Not Working
Quote:
but the printer font should be non-proportional, such as Courier
why use an ugly fixed width font?
textwidth and paddings can be worked out for any font using printer.textwidth(mystring)
i know using fixed width fonts is easier, but you are locked into using a very small number of fonts at specific sizes
Re: Printer.RightToLeft Not Working
Quote:
Originally Posted by westconn1
why use an ugly fixed width font?
Because most often it's the only way that actually works.
Personally, I'd rather choose what you called "ugly" font and no struggles.
Re: Printer.RightToLeft Not Working
Well, no one has told me yet why the printer.righttoleft is not working.
I can do the padding thing but I would rather not. But, I guess I am stuck with it for now.
Thanks all :)
Re: Printer.RightToLeft Not Working
I thought I did in post #2... :confused:
Quote:
Originally Posted by RhinoBull
RightToLeft property is designed to handle Right-To-Left Languages (Hebrew, Arabic, etc) so I think it depends on your locale.
Re: Printer.RightToLeft Not Working
Quote:
Originally Posted by RhinoBull
I thought I did in post #2... :confused:
That's correct. You did do it in Post #2. That will work. I was showing another alternative that I have used for years. So, we have supplied two solutions to the problem.
And, BTW. For years people lived with nonproportional fonts on typewriters and printers, showing all characters the same width. Nobody back then thought they were ugly. I guess times have really changed. :eek:
Re: Printer.RightToLeft Not Working
Ah... I'd rather replied to wiseoldman's statement:
Quote:
Originally Posted by wiseoldman
Well, no one has told me yet why the printer.righttoleft is not working...
... so I said "I thought I did...". :)
Best regards.