Question Display a multiplication table in a TextBox

Opprend

Member
Joined
Nov 5, 2013
Messages
8
Programming Experience
Beginner
Multiply.pngHi,

as a beginner, I coded a simple multiplication table and it works fine.
The data is displayed in a TextBox.
But the columns are not neat and straight.
My question is: how to display the table correctly without any awkwardness.

This is the code that displays the table:

txtDisplay.Text += number & " " & "x" & " " & factor & " " _
& "=" & " " & product & vbNewLine

I am using vs 2010.

Thank you.
 
Last edited:
Use the String.PadLeft() method. This will give you a uniform spacing between the strings. It returns a new string that right-aligns the characters by padding them with spaces on the left, for a specified total length. The total number of characters is the argument. In addition, you should use a font with uniform sizing for each character, such as Courier.
 
Alternatively, use the String.PadRight() method, which will left-align the characters by padding them with spaces on the right, for a specified total length.
 
Back
Top