With Append.Text on a multi-line textbox align right

Claude Larocque 666 Reputation points
2021-10-29T09:36:24.443+00:00

Hi everyone,
I try to find the way of aligning the currencies to the right as shown in the image below, here is the image followed by the code:

144991-aligncurrenciesright.gif

    Private Sub BtnAddToBasket_Click(sender As Object, e As EventArgs) Handles BtnAddToBasket.Click  
        OthersTC.SelectedTab = ReceiptTP  
        OrderTimeTB.Text = TimeOfDay  
        ReceiptTB.AppendText(vbTab + vbTab + vbTab & "AUTO-CAISSE ORDERING SYSTEMS")  
        ReceiptTB.AppendText(vbTab + vbTab + vbTab & "=========================================================================== " & vbNewLine)  
        ReceiptTB.AppendText(" " + vbNewLine)  
  
        ReceiptTB.AppendText("Name:" + vbTab + CustomerNameTB.Text + vbTab + "Phone No:" & CustomerPhoneTB.Text + vbTab +  
                     "Ref.No:" & ReferenceTB.Text + vbNewLine)  
        ReceiptTB.AppendText(vbNewLine + "Order date:" + vbTab & OrderDateTB.Text + vbTab + "Order time:" + vbTab & OrderTimeTB.Text + vbNewLine)  
        ReceiptTB.AppendText(vbNewLine + "Item type " + vbTab + vbTab & "Qty " + vbTab & "Unit Price:" + vbTab & "Sub Total " + vbNewLine)  
        ReceiptTB.AppendText(vbNewLine + "Nose ring: " + vbTab & Qty1TB.Text + vbTab & UnitPrice1TB.Text + vbTab + vbTab & SubTotal1TB.Text)  
        ReceiptTB.AppendText(vbNewLine + "Earings: " + vbTab + vbTab & Qty2TB.Text + vbTab & UnitPrice2TB.Text + vbTab + vbTab & SubTotal2TB.Text)  
        ReceiptTB.AppendText(vbNewLine + "Piercing jewelries: " + vbTab & Qty3TB.Text + vbTab & UnitPrice3TB.Text + vbTab + vbTab & SubTotal3TB.Text + vbNewLine)  
        ReceiptTB.AppendText(vbNewLine + vbTab + vbTab + vbTab & "Order sub total: " + vbTab & OrderSubTotalTB.Text + vbNewLine)  
        ReceiptTB.AppendText(vbNewLine + vbTab + vbTab + vbTab & "Tax1 on order: " + vbTab & Tax1TB.Text)  
        ReceiptTB.AppendText(vbNewLine + vbTab + vbTab + vbTab & "Tax2 on order: " + vbTab & Tax2TB.Text)  
        ReceiptTB.AppendText(vbNewLine + vbTab + vbTab + vbTab & "Tax3 on order: " + vbTab & Tax3TB.Text + vbNewLine)  
        ReceiptTB.AppendText(vbNewLine + vbTab + vbTab + vbTab & "Order total: " + vbTab & TotalTB.Text + vbNewLine)  
        ReceiptTB.AppendText(vbTab + vbTab + vbTab & "=========================================================================== " & vbNewLine)  
        ReceiptTB.AppendText(vbTab + vbTab + vbTab & "THANK YOU FOR SHOPPING WITH US" + vbNewLine)  
    End Sub  
Windows 10 Network
Windows 10 Network
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Network: A group of devices that communicate either wirelessly or via a physical connection.
2,276 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 32,076 Reputation points
    2021-10-29T21:03:17.77+00:00

    You have 9 characters in "Sub Total".

    Dim ColSize As Integer = 9
    ReceiptTB.AppendText(vbNewLine + vbTab + vbTab + vbTab & "Tax1 on order: " + vbTab & Strings.Right(Space(ColSize) & Tax1TB.Text, ColSize))
    

2 additional answers

Sort by: Most helpful
  1. David Joaquin Sanchez Lopez 21 Reputation points
    2021-10-29T14:23:05.84+00:00

    It is only a quick idea...

    string.padleft(MaximumLength)

    0 comments No comments

  2. Claude Larocque 666 Reputation points
    2021-10-29T18:23:26.977+00:00

    Thank you djanchezl,
    I would like to try your suggestion, can you show me where in my code I will put this?
    I am getting better in .net because of good programmer that helps like yourself.

    0 comments No comments