Results 1 to 4 of 4

Thread: [SOLVED] Listview Column Items As Strings?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    51

    Resolved [SOLVED] Listview Column Items As Strings?

    Well I'm newish to vb.
    I can't get something as simple as this to work

    basically what i need to do, is get two values of two items in two different columns of a listview into two strings, then do some other stuff but i know how to do that so dont worry.
    but after its done the other stuff i need it to go to the start and get the next two values and do it again until there arent any more.
    I know it's something about dim i as integer, etc. but im just confused.
    please help
    Last edited by allenk; May 5th, 2009 at 05:24 AM. Reason: mark as resolved

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Listview Column Items As Strings?

    Try doing something like this:
    Code:
    Private Sub Command1_Click()
    Dim myItem As String
    Dim mySubItem As String
    Dim i As Long
    
        With ListView1
            If .ListItems.Count = 0 Then Exit Sub
            For i = 1 To .ListItems.Count   '<<<indexing in listview begins with 1
                myItem = .ListItems(i).Text
                mySubItem = .ListItems(i).SubItems(1)
                
                'do your analyses here
                
            Next i
        End With
    
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    51

    Re: Listview Column Items As Strings?

    thats exactly what i was looking for.
    if theres some kind of voting system or something let me know. ill + you for sure.
    thanks allot mate.
    marked as resolved.

  4. #4
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Listview Column Items As Strings?

    Quote Originally Posted by allenk View Post
    thats exactly what i was looking for.
    if theres some kind of voting system or something let me know. ill + you for sure.
    thanks allot mate.
    marked as resolved.
    Yes, you can click the white flower like icon on the left of any useful post to rate it.
    Name:  rep.JPG
Views: 176
Size:  48.0 KB
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width