Results 1 to 12 of 12

Thread: eeek list view :@

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55

    eeek list view :@

    i got 2 colums renamed them to lstpric lst name the list view alltogether is called listview1

    so i did this code
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.  
    3.         ListView1.Items.Add(txtnam.Text)
    4.  
    5.  
    6.     End Sub

    that adds it to the lstname column how to make it add in the lst pric :/

    cheers

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    noone any other ideas :/

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    tahnk you and merry christmas n new year

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    you too mate!
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    that example works great but i cant seem to be getin another button to add up the ages :/ (or in my case prices) any code for that :/

    VB Code:
    1. Private Sub cmdcal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcal.Click
    2.         counteritem = lstboxpric.Items.Count - 1
    3.         For counter = 0 To counteritem
    4.             myvar = lstboxpric.Items.Item(Int(counter))
    5.  
    6.             If myvar = D Then
    7.                 num = D
    8.                 itotal = itotal + num
    9.                 BVAT.Text = "£ " & itotal.ToString
    10.             End If
    11.             If myvar = V Then
    12.                 num = V
    13.                 itotal = itotal + num
    14.                 BVAT.Text = Format(V, "##0.00").ToString
    15.                 BVAT.Text = "£ " & itotal.ToString
    16.             End If
    17.             If myvar = P Then
    18.                 num = P
    19.                 itotal = itotal + num
    20.                 BVAT.Text = Format(P, "##0.00").ToString
    21.                 BVAT.Text = "£ " & itotal.ToString
    22.             End If
    23.         Next
    24.         itotal = 0
    25.     End Sub

    i had that working but now i want to swich it to listview1 i want it to add the prices (where the age is in the example) any ideas :/

  7. #7
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    Code:
    Dim count As Integer
    Dim sum As Integer
    Dim lstItem As ListViewItem
    
    For count = 0 To ListView1.Items.Count - 1
         lstItem = ListView1.Items(count)
         sum = sum + CInt(lstItem.SubItems(1).Text)
    Next
    TextBox1.Text = sum
    this adds up the ages
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  8. #8
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    this works for the adding up as well

    Code:
    For count = 0 To ListView1.Items.Count - 1
           sum = sum + ListView1.Items(count).SubItems(1).Text
    Next
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  9. #9

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    VB Code:
    1. Private Sub CMDcalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDcalc.Click
    2.         Dim count As Integer
    3.         Dim sum As Double
    4.         Dim lstItem As ListViewItem
    5.  
    6.         For count = 0 To ListView1.Items.Count - 1
    7.             lstItem = ListView1.Items(count)
    8.             sum = sum + (lstItem.SubItems(1).Text)
    9.         Next
    10.         BVAT.Text = sum
    11.  
    12.  
    13.     End Sub

    im using that it works great cheers

    how can i format bvat.text so it shows only 2 decimal cuz 3.25 + 3.25 = 6.50 but in bvat.text it showed up as 6.5 :/

  10. #10
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    textbox1.text = format(sum, "#0.00")
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  11. #11

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    ONE LAST THING, how can i change a price in listview i no how to do it for listbox it wont work though

  12. #12

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    no one at all

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