Results 1 to 2 of 2

Thread: Adding rows to multi-column lstview

  1. #1
    PORRASTAR
    Guest

    Adding rows to multi-column lstview

    Hi
    I have a listview with 3 columns, namelly, colX, colY,colZ.
    I need to add co-ordinates to these columns from the following string:

    "cord1|colX = 1,colY=2,colZ=3;cord2|colX=3,colY=4,colZ=5"
    I only want to have the numbers within the string outputted in the lstview.
    Can anyone give me the code to do this please.
    Thanking you in advance
    PORRASTAR

  2. #2
    Hyperactive Member
    Join Date
    Feb 2001
    Location
    Belgium/Antwerp
    Posts
    275
    Option Explicit

    Private Start As Long
    Dim lUnique As Long

    Private Sub FillList()
    Dim s As String
    Dim i As Long
    Start = 1
    s = "cord1|colX=1,colY=2,colZ=3;cord2|colX=3,colY=45,colZ=5"
    Dim p As String
    With Me.lvwFiches.ListItems
    .Clear
    For i = 0 To 2
    lUnique = lUnique + 1
    p = Getval(s, "colX=")
    .Add lUnique, , p
    p = Getval(s, "colY=")
    .Item(lUnique).SubItems(1) = p
    p = Getval(s, "colZ=")
    .Item(lUnique).SubItems(2) = p
    Next i
    End With
    End Sub

    Private Function Getval(Arg As String, searchValue As String) As String
    Dim i As Long
    Dim j As Long
    i = InStr(Start, Arg, searchValue, vbTextCompare)
    j = InStr(i + 1, Arg, ",", vbTextCompare)
    Getval = Mid(Arg, i + Len(searchValue), j - (i + Len(searchValue)))
    Start = i + Len(searchValue)
    End Function


    Greetz, Luc

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