I need to use SPLIT on a lot of data, but I need to convert the array string to string.
I'm putting String () to get the string array variable, but VS keeps telling me that one-dimensional array can not be converted to string.
Can anyone help me?
I need to use SPLIT on a lot of data, but I need to convert the array string to string.
I'm putting String () to get the string array variable, but VS keeps telling me that one-dimensional array can not be converted to string.
Can anyone help me?
You can use the String.Join
method that you expect a separator, and parameters to concatenate and return a string (a collection in general). Example:
Dim result as String = String.Join("", array)
Catharina is not very clear about the situation you have, so it is difficult to give a categorical answer.
To concatenate items in an array in a single String, without tabs, you can use the # a>
To concatenate items in an array into a single string, including a separator string, the method, already indicated by others, is Join ()
To complete with items in an array a preformatted string, the preferred method is p>
Now you mentioned that you need to use SPLIT and I did not understand it, because #
Here are some examples. If you put your code here, it makes it much easier to give an answer.
Sub ExemplosStringArray()
Dim arrayOfString As String() = {"aaaa", "bbbb", "cccc"}
Dim concatStrings = String.Concat(arrayOfString)
MsgBox(concatStrings)
Dim joinedStrings = Join(arrayOfString, ";")
MsgBox(joinedStrings)
Dim formattedString = String.Format("Temos {0}, {1} e finalmente {2}", arrayOfString)
MsgBox(formattedString)
Dim multipartString = "dddd-eeee+ffff"
Dim arrayFromString = multipartString.Split("-"c, "+"c)
Dim newStringFromArray = Join(arrayFromString, vbCrLf)
MsgBox(newStringFromArray)
End Sub