How can I convert a string into an array?
The values are passed as a string:
Dim strInput as string
strInput = "Tom, John, Jason, Mike"
My error message is: Value of type 'String' cannot be converted to 'System.Array'
Use System.String.Split:
Dim source As String = "Tom, John, Jason, Mike"
Dim stringSeparators() As String = {","}
Dim result() As String
result = source.Split(stringSeparators, _
StringSplitOptions.RemoveEmptyEntries)
Or use Microsoft.VisualBasic.Strings.Split:
Dim source As String = "Tom, John, Jason, Mike"
Dim result() As String = Split(source, ",")
You can use split(). See here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With