Home All Groups Group Topic Archive Search About
Author
27 Apr 2006 5:38 PM
Lee
In VB6 you could use the format function to format strings using the @ and !
symbols. for example format("LEE", "!@@@@@@@@") would left align the string
"LEE" to the number of spaces allowed in the repeatings @'s. Has this
functionality disappeared in the format function for .NET, if so where has it
gone?

Author
27 Apr 2006 5:54 PM
Kerry Moorman
Lee,

One option might be to use String.PadLeft and/or String.PadRight.

Kerry Moorman


Show quoteHide quote
"Lee" wrote:

> In VB6 you could use the format function to format strings using the @ and !
> symbols. for example format("LEE", "!@@@@@@@@") would left align the string
> "LEE" to the number of spaces allowed in the repeatings @'s. Has this
> functionality disappeared in the format function for .NET, if so where has it
> gone?
Author
27 Apr 2006 5:56 PM
Mythran
"Lee" <L**@discussions.microsoft.com> wrote in message
news:7D04204B-3FE4-4F8F-A7D4-4053D3B2C102@microsoft.com...
> In VB6 you could use the format function to format strings using the @ and
> !
> symbols. for example format("LEE", "!@@@@@@@@") would left align the
> string
> "LEE" to the number of spaces allowed in the repeatings @'s. Has this
> functionality disappeared in the format function for .NET, if so where has
> it
> gone?

You can use the String.Format function to get the same results.

Using {0,-100} or {0, 100} to left/right align.

Dim input As String = "Test"
Dim result As String

result = String.Format("{0,-10}", input)
' result now contains "Test      "

result = String.Format("{0,10}", input)
' result now contains "      Test"

HTH,
Mythran
Author
27 Apr 2006 6:36 PM
Lee
I believe I found the answer to be LSET and RSET functions.

Thanks for your replies.
Author
27 Apr 2006 6:50 PM
Mythran
"Lee" <L**@discussions.microsoft.com> wrote in message
news:F9AF101B-A00A-45F2-865E-BB8AE318F1F2@microsoft.com...
>I believe I found the answer to be LSET and RSET functions.
>
> Thanks for your replies.

You should really check out the String.Format function :)  It will do what
you want, and MORE! :)

Mythran