471,073 Members | 1,295 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Repeat character x number of times

I think I've seen this before as a built-in function. I need a function that I pass it a character and a number and it returns that character repeated that many times. Easy enough to do myself, I just thought I remember a built-in function that did this? Does it exist?

Thanks,
--Michael
Nov 21 '05 #1
5 95289
New String(" ",10)
--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Raterus" <mo*********@suretar.reverse> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
I think I've seen this before as a built-in function. I need a function
that I pass it a character and a number and it returns that character
repeated that many times. Easy enough to do myself, I just thought I
remember a built-in function that did this? Does it exist?

Thanks,
--Michael
Nov 21 '05 #2
Raterus,
In addition to the other comments.

You can use:

System.String.New(Char, Integer)

Dim str As String
str = New String("x"c, 5)
Microsoft.VisualBasic.StrDup(Integer, Char)

Microsoft.VisualBasic.StrDup(Integer, Object)

Microsoft.VisualBasic.StrDup(Integer, String)

str = StrDup(5, "x"c)
str = StrDup(5, "xx")
System.String.PadLeft(Integer, Char)

System.String.PadRight(Integer, Char)

str = String.Empty.PadLeft(5, "x"c)

I normally use the first one, the StrDup is the String function from VB6.

The last two requires an existing string, so I normally would not use them
for this per se, I would use them when I needed to pad an existing string to
a certain number of characters...

Hope this helps
Jay
"Raterus" <mo*********@suretar.reverse> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
I think I've seen this before as a built-in function. I need a function
that I pass it a character and a number and it returns that character
repeated that many times. Easy enough to do myself, I just thought I
remember a built-in function that did this? Does it exist?

Thanks,
--Michael
Nov 21 '05 #3
"Raterus" <mo*********@suretar.reverse> wrote in message news:<u3**************@TK2MSFTNGP10.phx.gbl>...
I think I've seen this before as a built-in function. I need a function
that I pass it a character and a number and it returns that character
repeated that many times. Easy enough to do myself, I just thought I
remember a built-in function that did this? Does it exist?

Thanks,
--Michael

You are thinking of VB6's String() function:

String(7,65) '<-- creates string of 7 A's

AFAIK, there is not an eqivalent in the string class of VB.NET.
Nov 21 '05 #4
DenBorg,
Please read my previous post:
AFAIK, there is not an eqivalent in the string class of VB.NET.
VB6's string function is StrDup in VB.NET. You can also use the String
Constructor, samples are included in my previous post on this thread.

Hope this helps
Jay

"DenBorg" <de******@yahoo.com> wrote in message
news:dc**************************@posting.google.c om... "Raterus" <mo*********@suretar.reverse> wrote in message
news:<u3**************@TK2MSFTNGP10.phx.gbl>...
I think I've seen this before as a built-in function. I need a function
that I pass it a character and a number and it returns that character
repeated that many times. Easy enough to do myself, I just thought I
remember a built-in function that did this? Does it exist?

Thanks,
--Michael

You are thinking of VB6's String() function:

String(7,65) '<-- creates string of 7 A's

AFAIK, there is not an eqivalent in the string class of VB.NET.

Nov 21 '05 #5
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<ec**************@TK2MSFTNGP12.phx.gbl>...
AFAIK, there is not an eqivalent in the string class of VB.NET.


VB6's string function is StrDup in VB.NET. You can also use the String
Constructor, samples are included in my previous post on this thread.


That is very helpful to know. Thank you!
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Andrzej Jan Taramina | last post: by
5 posts views Thread by Lars | last post: by
37 posts views Thread by chandy | last post: by
2 posts views Thread by sachinik19 | last post: by
17 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
7 posts views Thread by =?Utf-8?B?cmF1bGF2aQ==?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.