I have some set of string values which has enter key as a delimeter in between and stored in the database. Now I have to split those string values using the split function and save it in an array.
//Code
Dim valuesArray as String()= Field.ListOfValues.Split(?)
How can I do that?
The "Enter" key you refer to could possibly be either a Carriage Return, or Line Feed or Both. The following uses ReadLine so this should do what you want and should account for variances in end of line characters
StreamReader.ReadLine Method
Reads a line of characters from the current stream and returns the data as a string.
A line is defined as a sequence of characters followed by a line feed ("\n"), a carriage return ("\r"), or a carriage return immediately followed by a line feed ("\r\n"). The string that is returned does not contain the terminating carriage return or line feed.
Dim valuesList As New List(Of String)
Using sr As New StreamReader(New System.IO.MemoryStream(System.Text.Encoding.ASCII.GetBytes(Field.ListOfValues)))
Do Until sr.EndOfStream
valuesList.Add(sr.ReadLine)
Loop
End Using
'If you really want an array convert it to one here:
Dim valuesArray As String() = valuesList.ToArray
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