-- 作者:裴保民
-- 发布时间:2018/1/29 9:08:00
-- 代码运行后出错
Dim dt_xyk As DataTable = DataTables("信用卡") Dim dt_lsz As DataTable = DataTables("流水账") Dim dt_dyyh As DataTable = DataTables("出账") dt_dyyh.DataRows.Clear Dim d As Date = new Date(Date.Today.Year, Date.Today.Month, 1) Dim ds() As Date = {d, d.AddMonths(1)} d = d.AddMonths(-1) For Each dr As DataRow In dt_xyk.DataRows Dim ndr As DataRow = dt_dyyh.AddNew ndr("账户名称") = dr("账户名称") ndr("卡号") = dr("卡号") ndr("账单日") = dr("账单日") ndr("起始记账日") = d.AddDays(dr("账单日")) ndr("本期支付") = dt_lsz.Compute("sum(金额)", "账户名称 = \'" & ndr("账户名称") & "\' and 日期 < #" & ndr("起始记账日") & "# and 类别 = \'转出\'") ndr("本期还款") = dt_lsz.Compute("sum(金额)", "账户名称 = \'" & ndr("账户名称") & "\' and 日期 < #" & ndr("起始记账日") & "# and 类别 = \'转入\'") ndr("信用额度") = dr("信用额度") ndr("本期应还") = ndr("本期支付") - ndr("本期还款") If dr("固定还款日") = False Then ndr("到期还款日") = cdate(ndr("起始记账日")).AddDays(dr("还款日")) Else If val(dr("还款日")) < val(dr("账单日")) Then ndr("到期还款日") = d.AddDays(dr("还款日")-1).AddMonths(1) Else ndr("到期还款日") = d.AddDays(dr("还款日")-1) End If End If If ndr("本期应还") > 0 Then If ndr("到期还款日") > Date.Today Then ndr("账单状态") = "已出账,没还款" Else ndr("账单状态") = "已出账,逾期还款" End If End If ndr("账单月") = Format(d, "yyyyMM") Next For Each d In ds For Each dr As DataRow In dt_xyk.DataRows Dim ndr As DataRow = dt_dyyh.AddNew ndr("账户名称") = dr("账户名称") ndr("卡号") = dr("卡号") ndr("账单日")=dr("账单日") ndr("起始记账日") = d.AddDays(dr("账单日")) ndr("本期支付") = dt_lsz.Compute("sum(金额)", "账户名称 = \'" & ndr("账户名称") & "\' and 日期 >= #" & ndr("起始记账日").addmonths(-1) & "# and 日期 <= #" & ndr("起始记账日")& "# and 类别 = \'转出\'") ndr("本期还款") = dt_lsz.Compute("sum(金额)", "账户名称 = \'" & ndr("账户名称") & "\' and 日期 >= #" & ndr("账单日").addmonths(-1) & "# and 日期 >= #" & ndr("起始记账日")& "# and 类别 = \'转入\'") Dim yq_out = dt_lsz.Compute("sum(金额)", "账户名称 = \'" & ndr("账户名称") & "\' and 日期 < #" & ndr("账单日").addmonths(-1) & "# and 类别 = \'转出\'") Dim yq_in = dt_lsz.Compute("sum(金额)", "账户名称 = \'" & ndr("账户名称") & "\' and 日期 < #" & ndr("账单日").addmonths(-1) & "# and 类别 = \'转入\'") ndr("信用额度") = dr("信用额度") ndr("本期应还") = ndr("本期支付") - ndr("本期还款") If dr("固定还款日") = False Then ndr("到期还款日") = cdate(ndr("起始记账日")).AddDays(dr("还款日")) Else If val(dr("还款日")) < val(dr("账单日")) Then ndr("到期还款日") = d.AddDays(dr("还款日")-1).AddMonths(1) Else ndr("到期还款日") = d.AddDays(dr("还款日")-1) End If End If If ndr("本期应还") > 0 Then If ndr("起始记账日")> Date.Today Then ndr("账单状态") = "未出账,没还款" Else ndr("账单状态") = "已出账,没还款" End If Else If ndr("起始记账日")> Date.Today Then ndr("账单状态") = "未出账,没还款" Else ndr("账单状态") = "已出账,已还款" End If End If ndr("账单月") = Format(d, "yyyyMM") Next Next
代码哪错了?运行后出错:
此主题相关图片如下:456.jpg
|