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

x
?
Solved

Populate list vist from text with visual basic .net

Posted on 2013-01-29
2
Medium Priority
?
239 Views
Last Modified: 2013-01-29
I have some output from Linux server that I would like to display in a list view.  I would like to remove the first 2 rows and show the rest.  Depending on the search , the number of rows can change.  Here is what the output looks like:


 Job Name Last Start Last End ST Run Pri/Xit
 ____________________________ ____________________ ____________________ __ _______ ___
 CLONB001 01/29/2013 07:30:18 01/29/2013 07:33:41 SU 1014638/1
 CLONS001 01/29/2013 07:30:19 01/29/2013 07:31:59 SU 1014638/1
 CLONS002 01/29/2013 07:32:01 01/29/2013 07:33:41 SU 1014638/1


How can I change my string to populate a list view, but remove the first 2 rows?
0
Comment
Question by:chadmanvb
[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
2 Comments
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 2000 total points
ID: 38831479
Dim lines As var = File.ReadAllLines(filePath).Skip(2)
For Each line As var In lines
    listView1.Items.Add(New ListViewItem(line.Split(' ')))
Next

Open in new window


that will get you all the lines besides the first 2, and populate your listview
0
 

Author Closing Comment

by:chadmanvb
ID: 38831925
Thanks!  I had to make some changes because of the way time could be displayed.  Here is what I ended up with

 'parse results and fill listview
        Dim intCount As Integer = 0
        ListView1.Items.Clear()
        Dim item1 As ListViewItem
        For Each line In strResults
            intCount += 1
            If intCount = 1 Or intCount = 2 Then
                'skip first 2 lines
            Else

                Dim strSplit() As String = line.Trim.Split(" ")
                item1 = New ListViewItem
                item1.Text = strSplit(0).ToString
                'figure out if a time is listed
                If strSplit(1).Trim = "-----" And strSplit(2) = "-----" Then
                    'MsgBox(line & "    *********NO TIME")
                    item1.SubItems.Add("NA")    'start time
                    item1.SubItems.Add("NA")    'end time
                    item1.SubItems.Add(GetStatus(strSplit(3)))  'status


                ElseIf strSplit(1).Trim = "-----" And strSplit(2) <> "-----" Then
                    'MsgBox(line & "    *********STOP")
                    item1.SubItems.Add("NA")    'start time
                    item1.SubItems.Add(strSplit(2) & " " & (strSplit(3)).ToString())  'end time
                    item1.SubItems.Add(GetStatus(strSplit(4)))  'status

                ElseIf strSplit(1).Trim <> "-----" And strSplit(3) = "-----" Then
                    'MsgBox(line & "    *********START")
                    item1.SubItems.Add(strSplit(1) & " " & (strSplit(2)).ToString())  'end time
                    item1.SubItems.Add("NA")    'start time
                    item1.SubItems.Add(GetStatus(strSplit(4)))  'status

                Else
                    'this is will show both start and stop time
                    'MsgBox(line & "    *********BOTH")
                    item1.SubItems.Add(strSplit(1) & " " & (strSplit(2)).ToString())  'end time
                    item1.SubItems.Add(strSplit(3) & " " & (strSplit(4)).ToString())  'start time
                    item1.SubItems.Add(GetStatus(strSplit(5)))  'status

                End If


                ListView1.Items.Add(item1)


            End If



        Next
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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