One thing you can do is to not repeat the same code endlessly:
tempresult = ""
If Not IsDBNull(sdr.Item("Arg0")) Then
tempresult = (sdr.Item("Arg0"))
If tempresult.Contains(",") Then
For Each s1 In (Split(tempresult))
Arg0.Add(s1)
Next
Else
Arg0.Add(tempresult)
End If
End If
Make this into a function like this:
Function SplitResults(ByVal Arg As String) As List(Of String)
Dim Result As List(Of String) = New List(Of String)()
If Not IsDbNull(Arg) Then
If Arg.Contains(",") Then
Result.AddRange(Split(Arg, ","))
Else
Result.Add(Arg)
End If
End If
Return Result
End Function
You would call it like this:
Arg1 = SplitResults(sdr.Item("Arg1"))
You could also convert the individual List(Of String)
variables to a List(Of List(Of String))
, which would still result in a ragged list that would be easier to loop through or search using LINQ.