Results 1 to 11 of 11

Thread: [RESOLVED] Printer.RightToLeft Not Working

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    57

    Resolved [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

  2. #2

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    57

    Re: Printer.RightToLeft Not Working

    I would like to right align some English text.

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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

  5. #5
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    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
    Doctor Ed

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  7. #7

  8. #8

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    57

    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

  9. #9

  10. #10
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Printer.RightToLeft Not Working

    Quote 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.
    Doctor Ed

  11. #11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width