Spaces function

J

John

Hi

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

Thanks

Regards
 
F

Fergus Cooney

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.
 
T

Tom Shelton

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.

One
 
F

Fergus Cooney

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
 
H

Herfried K. Wagner [MVP]

* "John said:
Is there a spaces(n) function equivalent in vb.net that returns a string of
spaces of length n?

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

Matthew Judd

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top