Enhanced Split Function for VB.NET
Category:
C#, VB.NET, ASP.NETType:
SnippetsDifficulty:
IntermediateAuthor: Alastair Vance
Version Compatibility: Visual Basic.NET
More information:
This split function supports delimiters within text qualifiers (i.e. ignores them!).
Place code on a form. Place a listvew control on the form. Set up view style as "details".
You will need to write a sub to call previewfile using the following parameters:
ByRef lv As ListView (listview name), ByVal FileName As String (delimited file name), ByVal Delimiter As String (delimiter character), ByVal Qualifier As String (qualifier character), ByVal IgnoreLines As Integer (number of lines to ignore at beginning)An Example:
Dim MySplitLine As Collection MyString = "1,""My Text"",5061,""Some more, text."",839" MySplitLine = SplitDelimitedLine(MyString, ",", """")This example would return 5 sections.
1
My Text
5061
Some more, text.
839
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations: