browse: forums | FAQ
Connecting Tech Pros Worldwide

Hey there! Do you need Visual Basic .NET help?

Get answers from our community of Visual Basic .NET experts on BYTES! It's free.

Spaces function

John
Guest
 
Posts: n/a
#1: Nov 20 '05
Hi

Is there a spaces(n) function equivalent in vb.net that returns a string of
spaces of length n?

Thanks

Regards





Fergus Cooney
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Spaces function


Hi John,

S = New String(" "c, 20)

Note the little 'c' which denotes a character as opposed to a string.

Regards,
Fergus

ps. I'm betting this is one of, oh, 5 replies.


Tom Shelton
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Spaces function


On 2003-10-15, Fergus Cooney <filter-1@tesco.net> wrote:[color=blue]
> Hi John,
>
> S = New String(" "c, 20)
>
> Note the little 'c' which denotes a character as opposed to a string.
>
> Regards,
> Fergus
>
> ps. I'm betting this is one of, oh, 5 replies.
>
>[/color]

One

--
Tom Shelton
MVP [Visual Basic]
Fergus Cooney
Guest
 
Posts: n/a
#4: Nov 20 '05

re: Spaces function


Hi Tom,

Yep, just the one! :-( I bet on the wrong horse - it was the 'vb.net
equivalent' that got the crowd gathering. But maybe there will be some
redundant additions in the morning, eh? Lol. Maybe you could add your version
of creating spaces just to cheer me up! ;-))

Regards,
Fergus


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#5: Nov 20 '05

re: Spaces function


* "John" <john@nospam.infovis.co.uk> scripsit:[color=blue]
> Is there a spaces(n) function equivalent in vb.net that returns a string of
> spaces of length n?[/color]

\\\
Dim s As String = New String(" "c, 60)
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Matthew Judd
Guest
 
Posts: n/a
#6: Nov 20 '05

re: Spaces function


Well, you can use the PadLeft and PadRight methods that
string variables have in .Net. For example:

Dim str As String
str.PadLeft(10)

effectively creates a string of 10 spaces.


[color=blue]
>-----Original Message-----
>Hi
>
>Is there a spaces(n) function equivalent in vb.net that[/color]
returns a string of[color=blue]
>spaces of length n?
>
>Thanks
>
>Regards
>
>
>.
>[/color]
Closed Thread