DataBind Listview to Text File in vb.net

I know it is a strange request. My argument was wouldn’t it be easier to just read the thing myself? Well that wasn’t what was asked and I suppose they had had their reasons. The text view looked like this:

        40^32^STD_EnrollmentStatus^EnrollmentStatus
        41^2^STD_EntitlementCode^EntitlementCode
        42^4^STD_Ethnicity^Ethnicity

Using the above data, after the GUI window opens, the contents of the listview will be taken from the 4th caret-delimited piece, and the contents of the listview will be:
        EnrollmentStatus
        EntitlementCode
        Ethnicity

So here is what I came up with:

Dim source As New List(Of SourceItem)
For Each line As String In File.ReadAllLines(filename)
   If line.Length > 0 Then
      source.Add(New SourceItem(line.Split("^"C)(3)))
   End If
Next
 
Public Class SourceItem
 
   Private string _data
 
   Public ReadOnly Property Data
      Get
         Return _data
      End Get
   End Property
 
   Public Sub New(data As String)
      _data = data
   End Sub
 
End Class
Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: