4 Replies - 656 Views - Last Post: 15 October 2008 - 04:32 PM Rate Topic: -----

#1 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 177
  • Joined: 11-October 08

Porblem with code to pluse the items type numbder in listview

Posted 15 October 2008 - 05:56 AM

I have ListView with many items of numbers type :
Items(0)= 10 , Items(1)= 5 , Items(2)= 3 , Items(3)= 2 items (i)
and I want to pluse all the item. I used this code to do this but it didn't success with me it pulse only tow items.

Dim i As Integer
		Dim j As Integer
		For i = 0 To ListView1.Items.Count - 1
			j = 0
			TextBox1.Text = Val(ListView1.Items(i).Text) + Val(ListView1.Items(j + 1).Text)
		Next i

This post has been edited by Mangore: 15 October 2008 - 05:57 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Porblem with code to pluse the items type numbder in listview

#2 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: Porblem with code to pluse the items type numbder in listview

Posted 15 October 2008 - 07:45 AM

You just keep adding item(i) with item(1) so by the end it will just equal the last item + the 2nd item.

What you want to do is this...


        Dim i As Integer
        Dim j As Integer
        For i = 0 To ListView1.Items.Count - 1
            j += CINT(ListView1.Items(i).Text)
        Next i
        TextBox1.Text = j.ToString()



This post has been edited by magicmonkey: 15 October 2008 - 07:46 AM

Was This Post Helpful? 0
  • +
  • -

#3 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 177
  • Joined: 11-October 08

Re: Porblem with code to pluse the items type numbder in listview

Posted 15 October 2008 - 08:59 AM

May you explain this please
j += CINT(ListView1.Items(i).Text)
Was This Post Helpful? 0
  • +
  • -

#4 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: Porblem with code to pluse the items type numbder in listview

Posted 15 October 2008 - 10:46 AM

it is the same as

j = j + val(listview1.items(i).text)
Was This Post Helpful? 0
  • +
  • -

#5 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 177
  • Joined: 11-October 08

Re: Porblem with code to pluse the items type numbder in listview

Posted 15 October 2008 - 04:32 PM

Thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1