Click to See Complete Forum and Search --> : [RESOLVED] żIs possible?


Marraco
June 11th, 2008, 12:34 PM
MyString = join({String1 , String2 , String3 , String4, String5},"") (it does not work)
_

GremlinSA
June 11th, 2008, 01:50 PM
Why whould you think that it works ???

Marraco
June 11th, 2008, 02:14 PM
Why whould you think that it works ???it needs to be:MyString = join(ArrayVariable,"")and I give the array {String1 , String2 , String3 , String4, String5} This works:ArrayVariable = {String1 , String2 , String3 , String4, String5}
MyString = join(ArrayVariable ,"") I have lines like:MyString = String1 & String2 & String3 & String4 & String5When two of the strings String# are long, that code is very slow. I have lines with a short number of long strings, and a large number of short strings. The time is proportional to the number of small strings, because for each short string, all the long lines are copied again.

String.Join() works much more faster, but I don't like dividing the code in many lines.
_

HanneSThEGreaT
June 12th, 2008, 01:15 AM
Marraco, have you seen this FAQ:
http://www.codeguru.com/forum/showthread.php?t=454776

or the StringArrayConverter thread:
http://www.codeguru.com/forum/showthread.php?t=454948

It may help

Marraco
June 12th, 2008, 08:05 AM
Marraco, have you seen this FAQ:
http://www.codeguru.com/forum/showthread.php?t=454776Yes, I had read it. (Thanks anyway for caring :) ). I fact I used String.Concat(data, data, data). Still I would like to know if there are a way, to use a string constant defined in place, in the way I have post.

For example, is valid to write:
Dim MyArray as String() = {data, data, data}but is invalid this line:String.Join("", {data, data, data} )maybe there is a way to do it that way, like:String.Join("", New String()={data, data, data} )
'(it does not work)

Just for curiosity.
_

Alsvha
June 12th, 2008, 08:37 AM
<snip>
String.Join("", New String()={data, data, data} )
'(it does not work)

Just for curiosity.
_

Remove the =

Marraco
June 12th, 2008, 08:45 AM
Remove the =Perfect. That is. :thumb:

PD:I wonder why Microsoft had made it different that in the Dim line.
_

HanneSThEGreaT
June 12th, 2008, 09:23 AM
PD:I wonder why Microsoft had made it different that in the Dim line.
_

With the declaration, if you are going to declare an array like that, you need to give it values, so that the array can be initialised.

With the Join statement, the Join function expects an array of values, that is why using an already existing array works in there, else, like with your code, you created an array of values on the fly ( inside the Join method ) - you are not assinging those values to a variable or array ( as you did with the declaration ), your just supplying values to the Join method to work properly.

Does that make sense ż

PS, I only now see what you wanted to achieve, sorry :p

Marraco
June 12th, 2008, 11:38 AM
With the declaration, if you are going to declare an array like that, you need to give it values, so that the array can be initialised.

With the Join statement, the Join function expects an array of values, that is why using an already existing array works in there, else, like with your code, you created an array of values on the fly ( inside the Join method ) - you are not assinging those values to a variable or array ( as you did with the declaration ), your just supplying values to the Join method to work properly.

Does that make sense żI was whining why "=" is not required in:Join(New String() {data,data,data},"") 'Is not Join(New String() = {data,data,data},"")When is required (as is reasonable) in:Dim MyArray As String() = {data,data,data}
PS, I only now see what you wanted to achieve, sorry :p Don't sorry. You give help. Thanks. :thumb: