• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VB.Net question with formatting Text

phantom404

Golden Member
I have a database with information and I want to display them in a form and on the form have a print button to print out the page.

Everything is done except I cant figure out how to get the text to line up in columns.

Ex.(how it looks now)
--------------------------------
| Michael 12344 |
| Rosie 456778 |
| Tony 54345 |
-------------------------------

I need it to look like this where no matter how long the name is the next column will start at a certain posistion
 
Use the PadRight class of String. So str.PadRight(20, " ") will put 20 empty spaces after the name. You'll need a set length, say 50. For the name then you would output str.Trim().PadRight(50-str.Length, " ")

Trevor
 
Sweet thanks alot had to modify it alittle because of .net 2005

LLength = LName.Length
LName = LName.PadRight(20 - LLength)

One problem im running into now is that the size of each letter is different its throwing off the line up of the columns....is there any way to take care of that.
 
Sweet, I figured it out. I mis read what PadRigth(x) did. I thought it started at the end of the string and counted for X amount of spaces to the right resulting in 20 all together using a first name with 7 characters. It turns out it starts from the begining of the string and coutns.
 
Back
Top