if the itemcheck is check then all the checks will be add separately to cash... i hope is it clear enough... thank You.. God bless...

Dim Cash As Double = 0.0
   Dim Cheque As Double = 0.0
   Dim Other As Double = 0.0
   Dim DetermineCash As Boolean
   Dim CheckedItems As ListView.CheckedListViewItemCollection = LstvwBankDeposits.CheckedItems
   Dim Item As New ListViewItem

           For Each Item In CheckedItems
                If (Item.SubItems(4).Text) = "Check" Then
                    DetermineCash = False
                    Cheque += Double.Parse(Item.SubItems(3).Text)
                ElseIf (Item.SubItems(4).Text) = "Cash" Then
                    DetermineCash = True
                    Cash += Double.Parse(Item.SubItems(3).Text)
                End If
            Next
            If LstvwBankDeposits.Items(1).SubItems(4).Text = "Cash" Then
                DetermineCash = True
                If e.CurrentValue = CheckState.Unchecked Then
                    Cash += Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                ElseIf e.CurrentValue = CheckState.Checked Then
                    Cash -= Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                End If
            ElseIf LstvwBankDeposits.Items(1).SubItems(4).Text = "Check" Then
                DetermineCash = False
                If e.CurrentValue = CheckState.Unchecked Then
                    Cheque += Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                ElseIf e.CurrentValue = CheckState.Checked Then
                    Cheque -= Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                End If
            End If

            If DetermineCash = True Then
                LblTotalCash.Text = CType(Cash, String)
                LblTotalCash.Text = FormatNumber(LblTotalCash.Text, 2)
                DetermineCash = False

            ElseIf DetermineCash = False Then
                LblTotalChecks.Text = CType(Cheque, String)
                LblTotalChecks.Text = FormatNumber(LblTotalChecks.Text, 2)
                DetermineCash = True

Recommended Answers

All 3 Replies

Possible solution located in similar thread.

oh hi.. still im working it out and your solution as well... hope i can get it... thanx

i got it... thank u for the help...

If e.CurrentValue = CheckState.Unchecked Then
                If LstvwBankDeposits.Items(e.Index).SubItems(4).Text = "Cash" Then
                    dblCash += Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                    LblTotalCash.Text = CType(dblCash, String)
                    LblTotalCash.Text = FormatNumber(LblTotalCash.Text, 2)
                    If LblTotalCash.Text < 0 Then
                        KLVProxy.StdMsgInformation("The Value is Invalid!", "Error", False)
                        LblTotalCash.Text = 0.0
                    End If

                ElseIf LstvwBankDeposits.Items(e.Index).SubItems(4).Text = "Check" Then
                    dblCheque += Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                    LblTotalCheques.Text = CType(dblCheque, String)
                    LblTotalCheques.Text = FormatNumber(LblTotalCheques.Text, 2)
                    If LblTotalCheques.Text < 0 Then
                        KLVProxy.StdMsgInformation("The Value is Invalid!", "Error", False)
                        LblTotalCheques.Text = 0.0
                    End If
                End If
            ElseIf e.CurrentValue = CheckState.Checked Then
                If LstvwBankDeposits.Items(e.Index).SubItems(4).Text = "Cash" Then
                    dblCash -= Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                    LblTotalCash.Text = CType(dblCash, String)
                    LblTotalCash.Text = FormatNumber(LblTotalCash.Text, 2)
                    If LblTotalCash.Text < 0 Then
                        KLVProxy.StdMsgInformation("The Value is Invalid!", "Error", False)
                        LblTotalCash.Text = 0.0
                    End If

                ElseIf LstvwBankDeposits.Items(e.Index).SubItems(4).Text = "Check" Then
                    dblCheque -= Double.Parse(Me.LstvwBankDeposits.Items(e.Index).SubItems(3).Text)
                    LblTotalCheques.Text = CType(dblCheque, String)
                    LblTotalCheques.Text = FormatNumber(LblTotalCheques.Text, 2)
                    If LblTotalCheques.Text < 0 Then
                        KLVProxy.StdMsgInformation("The Value is Invalid!", "Error", False)
                        LblTotalCheques.Text = 0.0
                    End If
                End If
            End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.