|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to use padright padleft to format text for display?I need to format some text that I display in the output window. I need to show something like this: *abcdef * *abcdefghij * Here is the code that I try, but ... str1 = "abcdef" Console.WriteLine("*" & str1.PadRight(20 - str1.Length) & "*") str1 = "abcdefghij" Console.WriteLine("*" & str1.PadRight(20 - str1.Length) & "*") the output window displays: *abcdef* *abcdefghij* how do I make it display like this? *abcdef * *abcdefghij * Thanks, Rich A quick look at the help for PadRight says the parameter is the total
length, so use PadRight(20) Show quoteHide quote "Rich" <R***@discussions.microsoft.com> wrote in message news:F0B07FD5-952C-4E8C-8587-9EE9F6DA5C6A@microsoft.com... > Greetings, > > I need to format some text that I display in the output window. I need to > show something like this: > > *abcdef * > *abcdefghij * > > Here is the code that I try, but ... > > str1 = "abcdef" > Console.WriteLine("*" & str1.PadRight(20 - str1.Length) & "*") > > str1 = "abcdefghij" > Console.WriteLine("*" & str1.PadRight(20 - str1.Length) & "*") > > the output window displays: > > *abcdef* > *abcdefghij* > > how do I make it display like this? > > *abcdef * > *abcdefghij * > > Thanks, > Rich Thanks. That did the trick.
Rich Show quoteHide quote "md" wrote: > A quick look at the help for PadRight says the parameter is the total > length, so use PadRight(20) > > "Rich" <R***@discussions.microsoft.com> wrote in message > news:F0B07FD5-952C-4E8C-8587-9EE9F6DA5C6A@microsoft.com... > > Greetings, > > > > I need to format some text that I display in the output window. I need to > > show something like this: > > > > *abcdef * > > *abcdefghij * > > > > Here is the code that I try, but ... > > > > str1 = "abcdef" > > Console.WriteLine("*" & str1.PadRight(20 - str1.Length) & "*") > > > > str1 = "abcdefghij" > > Console.WriteLine("*" & str1.PadRight(20 - str1.Length) & "*") > > > > the output window displays: > > > > *abcdef* > > *abcdefghij* > > > > how do I make it display like this? > > > > *abcdef * > > *abcdefghij * > > > > Thanks, > > Rich > > >
cut, copy, and paste
Reservation algorithm Sending Email via VB.Net displaying resource file as Help Multithreading with DirectoryServices Sql 2005 and vb 2005 question? Object Type Conversion Error Crystal Reports: long delay to open Converting C++ code to VB2005 How to collect the data from input created by document.write() in ASP.NET? |
|||||||||||||||||||||||