-
Jun 19th, 2017, 10:12 PM
#1
Thread Starter
Lively Member
[RESOLVED] string duplicates help easy one guys i hope
ok string is "hello"
strdup(100,"hello") only sends the h 1000 times how can i send the hello a 1000 times?????? as to say hellohellohello ect
Last edited by newbiedoobie1983; Jun 19th, 2017 at 10:22 PM.
-
Jun 19th, 2017, 10:30 PM
#2
Re: string duplicates help easy one guys i hope
There is no strdup method that is part of the .NET Framework so either it's your own or from a third party so we have no way of knowing what it does or is supposed to do. You're expecting us to perform magic.
-
Jun 19th, 2017, 10:34 PM
#3
Re: string duplicates help easy one guys i hope
If all you're asking, without actually asking, is how to create a String containing a number of copies of another String then you could do this:
vb.net Code:
Dim finalString = String.Concat(Enumerable.Range(1, copyCount).Select(Function(n) originalString))
That will create a list of 'copyCount' copies of 'originalString', concatenate them and put the result in 'finalString'.
-
Jun 20th, 2017, 04:00 AM
#4
Re: string duplicates help easy one guys i hope
Originally Posted by jmcilhinney
There is no strdup method that is part of the .NET Framework so either it's your own or from a third party so we have no way of knowing what it does or is supposed to do. You're expecting us to perform magic.
Microsoft.VisualBasic.Strings.StrDup Method
-
Jun 20th, 2017, 04:26 AM
#5
Re: string duplicates help easy one guys i hope
I do not think StrDup will use a string. I think it will use only a character.
I"m posting a less complex method than JMC's (not that his method has anything wrong of course)
Dim s As String = String.Join("", Enumerable.Repeat("hello", 100))
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jun 20th, 2017, 08:11 AM
#6
Re: string duplicates help easy one guys i hope
Originally Posted by Inferrd
Hmmm... I did search before posting and found nothing, but now I search again and I find that method. Not sure what I did last time but obviously something wrong.
-
Jun 20th, 2017, 08:13 AM
#7
Re: string duplicates help easy one guys i hope
Originally Posted by sapator
I do not think StrDup will use a string. I think it will use only a character.
I"m posting a less complex method than JMC's (not that his method has anything wrong of course)
Dim s As String = String.Join("", Enumerable.Repeat("hello", 100))
I wasn't aware of that Repeat method but it makes sense that it exists. That's an improvement on my effort but you've also taken a step backwards by using String.Join instead of String.Concat. They both join multiple substrings but Join puts a delimiter between each pair. If that delimiter is an empty String then the result is the same, so why require a delimiter at all?
-
Jun 20th, 2017, 08:18 AM
#8
Re: string duplicates help easy one guys i hope
Originally Posted by sapator
I do not think StrDup will use a string. I think it will use only a character.
As the documentation says, it will accept a String but it will only use the first character of it.
-
Jun 24th, 2017, 12:48 AM
#9
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|