经过几个小时的奋斗终于学习到Bin老师所指点的,感谢Bin老师,最后当中代码改为:
For t As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
sum1 =sum1 + tb.rows(t)("借方发生额")
sum2 =sum2 + tb.rows(t)("贷方发生额")
If tb.rows(t)("日期") <> #01/01/0001# Then
rt.Cells(t - p * prs + 2,0).Text = Format(tb.rows(t)("日期"),"yyyy年MM月dd日")
rt.Cells(t - p * prs + 2,1).Text = tb.rows(t)("摘要")
Dim money As Integer = tb.rows(t)("借方发生额")
If money > 0 Then
For i As Double = 9 To 2 Step - 1
rt.Cells(t - p * prs + 2, i).Text = GetDigit(Money,9-i)
If rt.Cells(t - p * prs + 2,i).Text = "¥" Then
Exit For
End If
Next
money = (tb.rows(t)("借方发生额") - money) * 100
If money > 0 Then
rt.Cells(t - p * prs + 2, 11).Text = GetDigit(Money,0)
Else
rt.Cells(t - p * prs + 2, 11).Text = 0
End If
If money > 10 Then
rt.Cells(t - p * prs + 2, 10).Text = GetDigit(Money,1)
Else
rt.Cells(t - p * prs + 2, 10).Text = 0
End If
End If
Dim money1 As Integer = tb.rows(t)("贷方发生额")
If money1 > 0 Then
For i As Double = 20 To 13 Step - 1
rt.Cells(t - p * prs + 2, i).Text = GetDigit(Money1,20-i)
If rt.Cells(t - p * prs + 2, i).Text = "¥" Then
Exit For
End If
Next
money1 = (tb.rows(t)("贷方发生额") - money1) * 100
If money1 > 0 Then
rt.Cells(t - p * prs + 2, 22).Text = GetDigit(Money1,0)
Else
rt.Cells(t - p * prs + 2, 22).Text = 0
End If
If money1 > 10 Then
rt.Cells(t - p * prs + 2, 21).Text = GetDigit(Money1,1)
Else
rt.Cells(t - p * prs + 2, 21).Text = 0
End If
End If
rt.Cells(t - p * prs + 2,23).Text = tb.rows(t)("汇款银行")
rt.Cells(t - p * prs + 2,24).Text = tb.rows(t)("款项来源")
End If
Next