Results 1 to 8 of 8

Thread: how to get sum of lisview vb.net in totalamount

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2017
    Location
    Philippines
    Posts
    12

    Post how to get sum of lisview vb.net in totalamount

    someone can teach me how to get the sum of specific column in listview to get the total amount and it goes to label.
    i hope someone can give me example for this.. thanks!

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: how to get sum of lisview vb.net in totalamount

    How are the values in the column formatted (i.e. $100.00 or similar)?

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: how to get sum of lisview vb.net in totalamount

    By the way... Your thread is a question, and not a Poll. I'll ask a moderator to revise your thread.

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2017
    Location
    Philippines
    Posts
    12

    Re: how to get sum of lisview vb.net in totalamount

    Quote Originally Posted by .paul. View Post
    By the way... Your thread is a question, and not a Poll. I'll ask a moderator to revise your thread.
    for example the column of listview total amount is column 5 then i want all total amount will apear at the label as long listview get the total amount of the certain column.. i need help!

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2017
    Location
    Philippines
    Posts
    12

    Re: how to get sum of lisview vb.net in totalamount

    can someone help me to fix this code:

    i want to subtract the quantity i add in the listview.

    this is my code:

    if i add the items into my listview my other listview productlistitems the qty will be minus.
    Code:
     Public Function saveOrderProduct(ByVal product_name) As Boolean
            'Saving Product'
            Dim lsv As Integer = CInt(FRMProductList.lsv_productlist.SelectedItems(0).SubItems(3).Text.ToString())
    
            Dim is_productfound As Boolean = False
            Dim regDate As Date = Date.Now()
            Dim strDate As String = regDate.ToString("dd-MM-yyyy")
            Dim cc As New Cashier_Class
            Dim pc As New Product_Class
            cc.product_name = FRMCashier.txt_productname.Text
            cc.product_category = FRMCashier.txt_productcategory.Text
            cc.product_price = Convert.ToDecimal(FRMCashier.txt_productprice.Text)
            cc.product_quantity = Convert.ToInt32(FRMCashier.txt_productquantity.Text)
            pc.product_name = cc.product_name
            pc.product_category = cc.product_category
            pc.product_price = cc.product_price
            pc.product_quantity = lsv - Convert.ToInt32(FRMCashier.txt_productquantity.Text)
            cc.product_total = Convert.ToDecimal(FRMCashier.txt_totalamount.Text)
            cc.prouct_date = strDate
            GLOBAL_VARS.product_itemsorder.Add(cc)
            Cashier_Class.populateProductOrder(FRMCashier.lsv_productitems)
            GLOBAL_VARS.product_list.Add(pc)
            Product_Class.populateProductlistsubtract(FRMProductList.lsv_productlist)
    
            MsgBox("Order Added", MsgBoxStyle.Information)
    
            Return (is_productfound)
    
        End Function
     Public Shared Sub populateProductlistsubtract(ByVal lsvproductlist As ListView)
            'Populate Productlist'
            lsvproductlist.Items.Clear()
            For Each pc As Product_Class In GLOBAL_VARS.product_list
                Dim pcl As Integer = lsvproductlist.Items.Count
                With lsvproductlist
                    .Items.Add(pc.product_name)
                    .Items(pcl).SubItems.Add(pc.product_category)
                    .Items(pcl).SubItems.Add(Convert.ToDecimal(pc.product_price))
                    .Items(pcl).SubItems.Add(Convert.ToDecimal(pc.product_quantity))
                End With
            Next
        End Sub
    Please someone help me to solve this problem.. HUHUHUHUHHU!!!
    Last edited by Shaggy Hiker; Mar 20th, 2017 at 10:29 AM. Reason: Added CODE tags.

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2017
    Location
    Philippines
    Posts
    12

    Re: how to get sum of lisview vb.net in totalamount

    it keeps add in the row of listview huhuhuhuhuhuh .. helpppppppppppppppppppp!!

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: how to get sum of lisview vb.net in totalamount

    I edited the post to add [CODE][/CODE] tags such that the code looks better. You can do this by pressing the # button and pasting the code between the resulting tags, or adding the code, then highlighting it and pressing the # button.
    My usual boring signature: Nothing

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2017
    Location
    Philippines
    Posts
    12

    Re: how to get sum of lisview vb.net in totalamount

    Code:
    Public Function saveOrderProduct(ByVal product_name) As Boolean
            'Saving Product'
            Dim lsv As Integer = CInt(FRMProductList.lsv_productlist.SelectedItems(0).SubItems(3).Text.ToString())
    
            Dim is_productfound As Boolean = False
            Dim regDate As Date = Date.Now()
            Dim strDate As String = regDate.ToString("dd-MM-yyyy")
            Dim cc As New Cashier_Class
            Dim pc As New Product_Class
            cc.product_name = FRMCashier.txt_productname.Text
            cc.product_category = FRMCashier.txt_productcategory.Text
            cc.product_price = Convert.ToDecimal(FRMCashier.txt_productprice.Text)
            cc.product_quantity = Convert.ToInt32(FRMCashier.txt_productquantity.Text)
            pc.product_name = cc.product_name
            pc.product_category = cc.product_category
            pc.product_price = cc.product_price
            pc.product_quantity = lsv - Convert.ToInt32(FRMCashier.txt_productquantity.Text)
            cc.product_total = Convert.ToDecimal(FRMCashier.txt_totalamount.Text)
            cc.prouct_date = strDate
            GLOBAL_VARS.product_itemsorder.Add(cc)
            Cashier_Class.populateProductOrder(FRMCashier.lsv_productitems)
            GLOBAL_VARS.product_list.Add(pc)
            Product_Class.populateProductlistsubtract(FRMProductList.lsv_productlist)
    
            MsgBox("Order Added", MsgBoxStyle.Information)
    
            Return (is_productfound)
    
        End Function
     Public Shared Sub populateProductlistsubtract(ByVal lsvproductlist As ListView)
            'Populate Productlist'
            lsvproductlist.Items.Clear()
            For Each pc As Product_Class In GLOBAL_VARS.product_list
                Dim pcl As Integer = lsvproductlist.Items.Count
                With lsvproductlist
                    .Items.Add(pc.product_name)
                    .Items(pcl).SubItems.Add(pc.product_category)
                    .Items(pcl).SubItems.Add(Convert.ToDecimal(pc.product_price))
                    .Items(pcl).SubItems.Add(Convert.ToDecimal(pc.product_quantity))
                End With
            Next
        End Sub
    I so confuse with my program huhuhu i need badly help.

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