charge invoice and sales invoice im using two listview , my problem is if the sales invoice is greater than charge invoice they cannot be diplay or charge invoice is greater than sales invoice also cannot be display but if they are both equal they display ? whats wrong with my code po.

both in crystal report

sales invoice charge invoice

        invoice no.        amount            invoice no.          customer name          amount

thats the tables looks like . in my crystal report, hope you can help fix it. need for my project

Private Sub ParaPrint()

    Dim ds As New DataSet1
    Dim dst As New DataTable

    Dim lvii As Integer
    Dim lvii2 As Integer

    lvii = ListView_salesInvoice.Items.Count - 1
    lvii2 = listview2_chargeinvoice.Items.Count - 1
    dst = ds.Tables.Add("Items")
    dst.Columns.Add("namecus", Type.GetType("System.String"))
    dst.Columns.Add("cashforward", Type.GetType("System.String"))

    dst.Columns.Add("Dateprint", Type.GetType("System.String"))

    dst.Columns.Add("saleinvo", Type.GetType("System.String"))
    dst.Columns.Add("chargeinvo", Type.GetType("System.String"))
    dst.Columns.Add("totalamount", Type.GetType("System.String"))

    dst.Columns.Add("invoOR", Type.GetType("System.String"))
    dst.Columns.Add("invoAmount", Type.GetType("System.String"))
    dst.Columns.Add("chargeOR", Type.GetType("System.String"))
    dst.Columns.Add("ChargeName", Type.GetType("System.String"))
    dst.Columns.Add("chargeAmount", Type.GetType("System.String"))
    Dim r As DataRow

    r = dst.NewRow()

    r("namecus") = frmOrderTransaction.lblname.Text
    r("Dateprint") = dets.ToString("MM/dd/yyyy")
    r("cashForward") = lblcashforward.Text
    r("saleinvo") = lblsalesamount.Text
    r("chargeinvo") = lblchargeamount.Text
    r("totalamount") = lbltotalamountcash.Text
    dst.Rows.Add(r)

    Dim lisg As ListViewItemCollection
    lisg = ListView_salesInvoice.Items

    Dim lsg As ListViewItemCollection
    lsg = listview2_chargeinvoice.Items

    Dim kkk = lisg.Count + lsg.Count
    If lisg.Count = lsg.Count And lisg.Count <> 0 And lsg.Count <> 0 Then

        For i = 0 To kkk - 1

            r = dst.NewRow()
            If lisg.Count <= kkk Then
                Try
                    r("invoOR") = lisg.Item(i).SubItems(1).Text
                    r("invoAmount") = FormatNumber(lisg.Item(i).SubItems(2).Text)
                Catch ex As Exception

                End Try

            End If

            If lsg.Count <= kkk Then
                Try
                    r("chargeOR") = lsg.Item(i).SubItems(1).Text
                    r("ChargeName") = lsg.Item(i).SubItems(2).Text
                    r("chargeAmount") = FormatNumber(lsg.Item(i).SubItems(3).Text)
                Catch ex As Exception

                End Try

            End If

            dst.Rows.Add(r)

        Next
    End If

    Dim objrpt As New SalesReporting

    objrpt.SetDataSource(ds.Tables(1))

    frmReport.crv1.ReportSource = objrpt
    frmReport.crv1.Refresh()
    frmReport.WindowState = FormWindowState.Normal
    frmReport.TopMost = True
    frmReport.ShowDialog()

End Sub

Dani AI

Generated

— quick diagnosis: your merge loop only runs when the two ListView counts are exactly equal, and the loop index is calculated from the sum of both counts. That combination plus the silent Try/Catch hides index errors, so rows only appear when the counts happen to match. Also double-check that the column names you add to the DataTable exactly match the names you use when assigning row values, and make sure the table you pass to CrystalReports matches the report's expected source.

Fix strategy (concise)

  • Iterate to the larger of the two ListView counts, not the sum, and check bounds before accessing each ListView.
  • Avoid empty Try/Catch blocks; log or Debug.WriteLine exceptions so you see what fails.
  • Use Decimal.TryParse for amounts and store numeric values in numeric columns; format for display only when needed.
  • Pass the exact DataTable (or DataSet) the report expects, e.g. ds.Tables("Items") or the typed DataSet that the report was built against.

Example VB.NET pattern to merge rows safely:

Dim lvS = ListView_salesInvoice.Items
Dim lvC = listview2_chargeinvoice.Items
Dim maxCount = Math.Max(lvS.Count, lvC.Count)

For i As Integer = 0 To maxCount - 1
    Dim rw As DataRow = dt.NewRow()
    If i < lvS.Count Then
        rw("invoOR") = lvS(i).SubItems(1).Text
        Dim a As Decimal
        Decimal.TryParse(lvS(i).SubItems(2).Text, a)
        rw("invoAmount") = a
    End If
    If i < lvC.Count Then
        rw("chargeOR") = lvC(i).SubItems(1).Text
        rw("ChargeName") = lvC(i).SubItems(2).Text
        Dim b As Decimal
        Decimal.TryParse(lvC(i).SubItems(3).Text, b)
        rw("chargeAmount") = b
    End If
    dt.Rows.Add(rw)
Next
objrpt.SetDataSource(ds.Tables("Items"))

Quick troubleshooting tips: insert Debug.WriteLine to show lvS.Count, lvC.Count and i while looping; verify SubItems indexes (0 is the first column); confirm the report was designed against the same DataTable schema; and remove any catch blocks that swallow errors. Good call by to add debug checks — that will make the real error visible.

Odd use of capstone, but capstone course would make sense.

A capstone course, also known as capstone unit or a senior thesis or senior seminar serves as the culminating and usually integrative experience of an educational program. ... The term derives from the final decorative coping or "cap-stone" used to complete a building or monument.

Back to your issue. Usually I have to put in debug statements to see where the issue is. But as you are not using VB.net, C# or such you'll have to leverage what your system has to find why the values diverge.

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.