Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,303 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,476 people online right now. Registration is fast and FREE... Join Now!




Porblem with code to pluse the items type numbder in listview

 
Reply to this topicStart new topic

Porblem with code to pluse the items type numbder in listview

Mangore
15 Oct, 2008 - 04:56 AM
Post #1

D.I.C Head
**

Joined: 11 Oct, 2008
Posts: 80

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.

CODE
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 Oct, 2008 - 04:57 AM
User is offlineProfile CardPM
+Quote Post

magicmonkey
RE: Porblem With Code To Pluse The Items Type Numbder In Listview
15 Oct, 2008 - 06:45 AM
Post #2

D.I.C Regular
***

Joined: 12 Sep, 2008
Posts: 418



Thanked: 68 times
My Contributions
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...

vb


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 Oct, 2008 - 06:46 AM
User is online!Profile CardPM
+Quote Post

Mangore
RE: Porblem With Code To Pluse The Items Type Numbder In Listview
15 Oct, 2008 - 07:59 AM
Post #3

D.I.C Head
**

Joined: 11 Oct, 2008
Posts: 80

May you explain this please
j += CINT(ListView1.Items(i).Text)
User is offlineProfile CardPM
+Quote Post

magicmonkey
RE: Porblem With Code To Pluse The Items Type Numbder In Listview
15 Oct, 2008 - 09:46 AM
Post #4

D.I.C Regular
***

Joined: 12 Sep, 2008
Posts: 418



Thanked: 68 times
My Contributions
it is the same as

j = j + val(listview1.items(i).text)


User is online!Profile CardPM
+Quote Post

Mangore
RE: Porblem With Code To Pluse The Items Type Numbder In Listview
15 Oct, 2008 - 03:32 PM
Post #5

D.I.C Head
**

Joined: 11 Oct, 2008
Posts: 80

Thank you

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:28AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month