473,224 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 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 97142
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrzej Jan Taramina | last post by:
I have a need to convert a number into the character that it represents. For example, if I have: <xsl:variable name="number" select="169"/> I want to be able to convert this to the...
5
by: Lars | last post by:
Why doesn't the W3C's HTML Validator recognize &euro; and what do I have to do to make my html-file valid?
37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
4
by: harry | last post by:
Hi, I would like to find command like: RepeatThisCharacterXTimes(CharacterToRepeat, TimesToRepeat) Dim MyString as String = RepeatThisCharacterXTimes("x", 5) MyString is now 'xxxxx' I'm...
2
by: sachinik19 | last post by:
Hi, We are using SAXParser (xerces) for parsing an xml with utf-8 encoding. For some special character it gives SAXException with error message - "The invalid character is found in the document...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
7
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
Hi: vs2008 c# Having a string myvar = "*"; I need to repeat this myvar 100 times when is used at run time... string myline = myvar + myvar+ myvar....(100 times) What the easiest way to...
5
by: win_cpp | last post by:
Hello, I was wondering if there is something equivalent to 'Repeat' pattern in C# where I can say, Repeat(10) myobj.SayHi(); The expansion of this being, for (int i = 0; i < 10; ++i)
3
by: Colt | last post by:
I have this program that an associate will input their ID# then it prints back saying (your associate ID# is XXX) then it will state what time it they clocked in/out--Ex: Your ID# is 101 and you left...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.