Here's the function.
A sample call would be:
strLine = objSplit.SplitLine(strTemp, ",", """"
where strTemp is the current line string, comma is the delimiter, a double quote is the text qualifier, and strLine is a string array.
Hope this helps
Public Function SplitLine(ByVal Line As String, ByVal Delimiter As String, ByVal TextQualifier As String) As String()
Dim arrNewLine As New ArrayList()
Dim chCurrent As Char
Dim intPos As Integer
Dim strTemp As String
Dim strNewLine As String()
Dim bolInsideQualifier As Boolean
For intPos = 0 To (Line.Length - 1)
chCurrent = Line.Substring(intPos, 1)
Select Case True
Case chCurrent = Delimiter.Substring(0, 1) And Not bolInsideQualifier
'Check for single or multi-character delimiters
If Line.Substring(intPos, Len(Delimiter)) = Delimiter Then
intPos += Len(Delimiter) - 1 'Increment position For multi-character delimiters
arrNewLine.Add(strTemp)
strTemp = ""
Else
strTemp &= chCurrent
End If
Case bolInsideQualifier And chCurrent = TextQualifier
If intPos < (Line.Length - 1) Then
'Check to see if it's a double qualifier eg. ""
If Line.Substring(intPos + 1, 1) = TextQualifier Then
strTemp &= chCurrent
intPos += 1
Else
'Toggle the Qualifier
bolInsideQualifier = False
End If
Else
'Toggle the Qualifier
bolInsideQualifier = False
End If
Case Not bolInsideQualifier And chCurrent = TextQualifier
bolInsideQualifier = True
Case Else
strTemp &= chCurrent
End Select
Next
'Add last field to arraylist
arrNewLine.Add(strTemp)
ReDim strNewLine(arrNewLine.Count - 1)
'Convert To String Array
For intPos = 0 To arrNewLine.Count - 1
strNewLine(intPos) = arrNewLine.Item(intPos)
Next
Return strNewLine
End Function