CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Add numbers

  1. #1
    Join Date
    Apr 2001
    Posts
    4

    Add numbers

    Hi Everyone,

    I have added a ListView control to a form with 4 columns. I would like to add the numbers together that are in column 2 to come up with a total for that column. Does anyone have any ideas how to go about accomplishing this? I would appreciate any help. Thank you.


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Add numbers

    This should do what you are trying to do. THe sample assumes the column to Total is Column 2
    ---> Subitems(1)

    private Sub Command1_Click()
    Dim x as Integer
    Dim Total as Long
    for x = 1 to listView1.ListItems.Count
    Total = Total + CLng(lv.ListItems(x).SubItems(1))
    next x
    MsgBox Format(Total, "###,###,###,##0")
    End Sub




    John G

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

Featured