Results 1 to 15 of 15

Thread: [RESOLVED] Text File Column Alignment While Printing

Hybrid View

  1. #1
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Text File Column Alignment While Printing

    I should have said this in the other thread. Don't mix tabs and padding.

    I'd switch the font to mono-spaced (Courier) with padding or figure out the correct tab stops, which won't be the same in a textbox and printer.

    Courier is pretty common in printers.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  2. #2

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: Text File Column Alignment While Printing

    Am i correct in saying PadRight will move the next string so many spaces to the right?

    If so i dont think think this method will work due to when the string increases in chartacters the columns do not line up which seems to be happing no matter how i try to implment it.
    Code:
                sw.WriteLine("".PadRight(20, " "c) & "Name".PadRight(20, " "c) & _
                            "Material".PadRight(120, " "c) & _
                            "Length".PadRight(15, " "c) & _
                            "Qty".PadRight(8, " "c) & _
                            "Units".PadRight(8, " "c)) ' & _
             
                sw.WriteLine("")
                Dim i As Int16
                With Me.ListView1
                    For i = 0 To CShort(.Items.Count - 1)
                        If .Items(i).Text <> "" Then
                            sw.WriteLine("".PadRight(20, " "c) & .Items(i).Text.PadRight(20, " "c) & _
                            .Items(i).SubItems(1).Text.PadRight(120, " "c) & _
                            .Items(i).SubItems(2).Text.PadRight(15, " "c) & _
                            .Items(i).SubItems(3).Text.PadRight(8, " "c) & _
                            .Items(i).SubItems(4).Text.PadRight(8, " "c)) ' & _
                             sw.WriteLine("")
                        End If
                    Next
                End With

  3. #3

    Re: Text File Column Alignment While Printing

    Code:
            Dim aString As String = "1234", eString As String = "END"
            Debug.WriteLine("Debug Output Follows")
            For padCtr As Integer = 1 To 10
                Debug.WriteLine(aString.PadRight(aString.Length + padCtr, "*") & eString)
            Next
    Debug Output Follows
    1234*END
    1234**END
    1234***END
    1234****END
    1234*****END
    1234******END
    1234*******END
    1234********END
    1234*********END
    1234**********END

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