VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Dedupe ListView Function with a recordset. Also shows how to do some simple math .This funtion is m

by Joe Momma (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 23rd April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Dedupe ListView Function with a recordset. Also shows how to do some simple math .This funtion is meant to be used when passing values from

API Declarations


With rs ' Recordset
On Error Resume Next


Do While Not .EOF'list products of a specific category on ListView starts Loop
Set rs = ListView2.ListItems.Add(, , !Productid, 1, 1)
rs.SubItems(1) = !ProductName
rs.SubItems(2) = !Unit
rs.SubItems(3) = Format(!PRICE, "Currency")
rs.SubItems(4) = Format(!Extcost, "Currency")
rs.SubItems(5) = Format(!Retail, "Currency")
rs.SubItems(6) = Format(!Add)
cTotal = cTotal + CCur(rs.SubItems(3)) * (rs.SubItems(6)) ' here the math part , really simple CCur sets it as Currency
rs.SubItems(7) = Format(cTotal, "Currency")
.MoveNext ' Restarts Loop till EOF
Loop
.Close

End With
Call RemoveDupes(ListView2)
ListView2.Refresh
End Sub


Rate Dedupe ListView Function with a recordset. Also shows how to do some simple math .This funtion is m



    Dim i As Integer
    Dim x As Integer


    For i = listview.ListItems.Count To 1 Step -1 ' Works backwards avoiding Error


        For x = listview.ListItems.Count To 1 Step -1 ' same
            If i = x Then Goto Nextx 'adds item if Not In recieving listview.Once one is in there it will actually start the below routine
            


            If LCase(listview.ListItems(x)) = LCase(listview.ListItems(i)) Then
                listview.ListItems.Remove (i) 'that should be clear
                listview.Refresh 'Better To be safe Then dead
                i = listview.ListItems.Count 'sets i To current record count so you dont Get an Error when the Loop starts again
            End If
        Nextx:
    Next x
Next i
End Sub

Download this snippet    Add to My Saved Code

Dedupe ListView Function with a recordset. Also shows how to do some simple math .This funtion is m Comments

No comments have been posted about Dedupe ListView Function with a recordset. Also shows how to do some simple math .This funtion is m. Why not be the first to post a comment about Dedupe ListView Function with a recordset. Also shows how to do some simple math .This funtion is m.

Post your comment

Subject:
Message:
0/1000 characters