Resolved Multiple Splits for Listview

Puddings

New member
Joined
Nov 13, 2010
Messages
4
Programming Experience
Beginner
I am having problem with using multiple Splits for an entry to be populated to my listview columns.

Here is my code:
VB.NET:
    Sub AddProcess(ByVal client As Connection, ByVal strings() As String)
        For i = 1 To UBound(strings)
            Dim firstsplit() As String = strings(i).Split("|")
            Dim item1 As New ListViewItem(firstsplit(0))
            item1.SubItems.Add(firstsplit(1))
            Dim secondsplit() As String = firstsplit(1).Split(":")
            item1.SubItems.Add(secondsplit(1))
            lstMon.Items.AddRange(New ListViewItem() {item1})
        Next i
    End Sub

Basically I am sending packets from my client with | and : as separators. (E.g A|B:C)

Now I am trying display the result in 3 different columns of my listview and to split them into 3 parts. From my code above, what I am getting is A, B:C, and C in my columns instead of A, B, and C. I know the problem is due to the firstsplit itself where its only splitting the packet based on | while leaving the B:C as a result. I can't figure out how to split them to A, B and C.

Any help would be appreciated. :eek:
 
Last edited:
You only need one Split operation because you can supply an array of Char values:
VB.NET:
Dim value = "A|B:C"
Me.lstMon.Items.Add(New ListViewItem(value.Split("|:".ToCharArray)))
 
Back
Top