How to add array items to a string
Hi,
I have a array named item(3) which contains 4 strings.
i.e.
item(0) = hallo
item(1) = how
item(2) = are
item(3) = you?
Now, i would like these 4 elements in one string named AllTekst.
I decladed AllTekst as a string, but vb says it cannot cast an 1 dimensional array to type string.
Can somebody help me?
Thanks in advance.
Niels
Re: How to add array items to a string
Hi,
Must be somethin peculiar in your code. Please post it.
Re: How to add array items to a string
Hi
have you tried something like this?
Code:
AllTekst = item(0) & item(1) & item(2) & item(3)
Regards
Jorge
Re: How to add array items to a string
no that makes sense... you can't assign an array to a string, because it doesnt know what you REALLY want to do is put all values of the elements of the array into the string.. all VB sees is you trying to say
string = array
Code:
Dim MyString As String
For i As Integer = 0 To item.GetUpperBound(0)
MyString &= item(i)
Next
if you are putting a sentence together.. you may want to add spaces in between words..
MyString &= item(i) & " "
Re: How to add array items to a string
Thank you!, this is what i needed!!
Re: How to add array items to a string
It may be intentional, but the first word is generally spelled hello rather than hallo.