Question adding space in string from table

Joined
Jun 17, 2014
Messages
7
Programming Experience
Beginner
hi, i want to create a string (fixed length) from ms. access table..

and this is the data from table "data" with 2 field (Name(text (15)), address(text(15))

and here is the data from table

name= Sonny (5 char)
address = visualbasic (11 char)


all i can do is create string from table
VB.NET:
"Sonnyvisualbasic"

i want to create fixed length so the output like this
VB.NET:
"Sonny          visualbasic    "


help me please, thanks :)
 
This thread of mine shows you how to create text with fixed-width columns:

Formatting Fixed-width Text Output

It calls `AppendFormat` on a `StringBuilder` object but you can also call `String.Format` with the same arguments to create a single `String` or do similarly for any method that performs complex formatting. In your case, the format string would be "{0,-15}{1,-15}".
 
This thread of mine shows you how to create text with fixed-width columns:

Formatting Fixed-width Text Output

It calls `AppendFormat` on a `StringBuilder` object but you can also call `String.Format` with the same arguments to create a single `String` or do similarly for any method that performs complex formatting. In your case, the format string would be "{0,-15}{1,-15}".

thanks, you're a great help :D
 
Back
Top