[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

vb.net - add item to listview

Posted on 2013-01-21
1
Medium Priority
?
521 Views
Last Modified: 2013-01-21
hello,
I have this little code here to load data into a listview from a text file..
how can I change that up so it loads from a string called "strData"
that has the records line by line

            Using sr As New System.IO.StreamReader(strData, True)
                While Not sr.EndOfStream
                    strLine = sr.ReadLine
                    If strLine <> "" And Not strLine.StartsWith("#") Then
                        tabLine = strLine.Split(strSept)
                        lItem = lstView.Items.Add(tabLine(0))
                        For j As Integer = 1 To tabLine.GetUpperBound(0)
                            lItem.SubItems.Add(tabLine(j))
                        Next j
                        For j As Integer = tabLine.Count To 5
                            lItem.SubItems.Add(tabReplace(j))
                        Next j

                        lItem.SubItems(3).Text = "0"
                        lItem.SubItems(4).Text = "0"
                    End If
                End While
            End Using

Open in new window

0
Comment
Question by:XK8ER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 38803866
Just use Split() on strData with a For loop:
        For Each strLine In strData.Split(vbCrLf.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
            If strLine <> "" And Not strLine.StartsWith("#") Then
                tabLine = strLine.Split(strSept)
                lItem = lstView.Items.Add(tabLine(0))
                For j As Integer = 1 To tabLine.GetUpperBound(0)
                    lItem.SubItems.Add(tabLine(j))
                Next j
                For j As Integer = tabLine.Count To 5
                    lItem.SubItems.Add(tabReplace(j))
                Next j

                lItem.SubItems(3).Text = "0"
                lItem.SubItems(4).Text = "0"
            End If
        Next

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question