Dim lst As new List(of DataRow)
Dim prj As List(Of String) = DataTables("表A").GetValues("项目")
For Each s As String In prj
Dim dr As DataRow = DataTables("表A").Find("项目 = '" & s & "' and 余额 <= 0","日期 desc")
If dr IsNot Nothing Then
Dim drs As List(Of DataRow) = DataTables("表A").Select("项目 = '" & s & "' and 日期 > #" & dr("日期") & "#")
If drs.Count > 0 Then lst.AddRange(drs.ToArray)
End If
Next
For Each d As DataRow In lst
Output.Show(d("余额"))
Next