Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How can summarize item in a listview

Posted on 2004-10-28
Medium Priority
Last Modified: 2013-12-26
I have the following 2 field in a grid
GroupField   TotalField
AAA            1
BBB            1
CCC            1
AAA            1
BBB            2
CCC            1
AAA            1
BBB            1
Now i need to provide a summary in a listview as follows

GroupField   TotalField
AAA             3
BBB            4
CCC            2

I have done the following

Private sub SetupListview

      with lvw.ColumnHeaders
          .Add, "Grp","Group,2000
            .Add, "Ttl","Total,2000
      end with
end sub

Private sub PopulateListView(Byval strGroup as string,intValue as integer)
      dim li as listItem
        dim liKey as string

liKey="k" & StrGroup
      if lvw.listitems.count > 0 Then

            for each li in lvw.listitems
                  if li.text=strGroup then
                        li.subItems(1)=IntValue + 1
                        SET LI=LVW.ListItems.Add(,likey,strGroup)
                  end if
            SET LI=LVW.ListItems.Add(,likey,strGroup)
      end if

end sub
Question by:Gabriel_Brienza
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
LVL 14

Accepted Solution

Shiju Sasidharan earned 120 total points
ID: 12436130
try this

Private Sub PopulateListView(ByVal strGroup As String, intValue As Integer)
Dim lst As ListItem
     Set lst = lvw.FindItem(strGroup, lvwText, , lvwWhole)
     If lst Is Nothing Then
         Set lst = lvw.ListItems.Add(, , strGroup)
            lst.SubItems(1) = intValue
        lst.SubItems(1) = CInt(lst.SubItems(1)) + intValue
     End If
     Set lst = Nothing
End Sub

Author Comment

ID: 12442251
fantastic .it worked very well

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 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