Board index » Visual Studio » String format, minimum width.
|
TimJackson
|
|
TimJackson
|
String format, minimum width.
Visual Studio92
Hi, Dumb question for you: Is there a quick and easy way to ensure a string has a minimum width using format specifier? Should I just write if myString.Length < 8 then myString.PadLeft ( ...... ) ? Thanks - |
| Mattias
Registered User |
Mon Nov 05 11:20:19 PST 2007
Re:String format, minimum width.QuoteShould I just write myString = myString.PadLeft(8) What do you mean by format specifier? Do you get myString from a call to String.Format or some other formatting method? Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org www.msjogren.net/dotnet/">www.msjogren.net/dotnet/ | www.dotnetinterop.com">www.dotnetinterop.com Please reply only to the newsgroup. - |
| Tom
Registered User |
Mon Nov 05 21:11:15 PST 2007
Re:String format, minimum width.
On Nov 5, 8:45 am, "Jameson" <rtgro...@hotmail.com>wrote:
QuoteHi, dim sMessage as string = string.format("{0,-8}", value) If value is less then 8 characters, the result will be an 8 character string left padded with spaces. To right pad, make the value after the comma a positive number. HTH -- Tom Shelton - |
