|
-
May 1st, 2008, 06:48 AM
#1
Thread Starter
Member
[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
-
May 1st, 2008, 07:47 AM
#2
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?
-
May 1st, 2008, 08:03 AM
#3
Thread Starter
Member
Re: Printer.RightToLeft Not Working
I would like to right align some English text.
-
May 1st, 2008, 09:44 AM
#4
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
-
May 1st, 2008, 12:14 PM
#5
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
-
May 1st, 2008, 04:51 PM
#6
Re: Printer.RightToLeft Not Working
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 1st, 2008, 06:23 PM
#7
Re: Printer.RightToLeft Not Working
 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.
-
May 1st, 2008, 08:06 PM
#8
Thread Starter
Member
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
-
May 1st, 2008, 08:51 PM
#9
Re: Printer.RightToLeft Not Working
I thought I did in post #2...
 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.
-
May 2nd, 2008, 09:10 AM
#10
Re: Printer.RightToLeft Not Working
 Originally Posted by RhinoBull
I thought I did in post #2... 
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.
-
May 2nd, 2008, 12:54 PM
#11
Re: Printer.RightToLeft Not Working
Ah... I'd rather replied to wiseoldman's statement:
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|