在数据窗口中,如果有三条记录,然后对这三条记录进行整理,如果数量为0或名称为空,则删除,但如果第一条数量为0要删除的话,则PB报错退出,用的是PB9,代码如下:
rowcount = dw_detail.rowcount()
for i = 1 to rowcount
delrow = rowcount + 1 - i
quantity = dw_detail.getitemdecimal(delrow, 'quantity')
retprice = dw_detail.getitemdecimal(delrow, 'price')
itemcode = dw_detail.getitemstring(delrow, 'chargecode')
if itemcode = '' or isnull(itemcode) or isnull(quantity) or quantity = 0 or isnull(retprice) then
dw_detail.deleterow(delrow)
end if
next
------解决方案--------------------
这是得注意一下:
for i = 1 to rowcount //这里要倒着删:for i = rowcount to 1 step -1
------------
原因自己捉摸捉摸。
------解决方案--------------------
很长时间没用pb了,,都忘了差不多了,,你试试这样行不行
- Delphi(Pascal) code
for i=rowcount to 1 step -1quantity = dw_detail.getitemdecimal(i, 'quantity')retprice = dw_detail.getitemdecimal(i, 'price')itemcode = dw_detail.getitemstring(i, 'chargecode')if itemcode = '' or isnull(itemcode) or isnull(quantity) or quantity = 0 or isnull(retprice) then dw_detail.deleterow(i)end ifnext
------解决方案--------------------
------解决方案--------------------
当真还没注意看呢。。。
那报的什么错呢?
------解决方案--------------------
看看是不是数据窗口某个事件代码引起的,试着注销这个数据窗口事件里的代码看看
------解决方案--------------------
rowcount = dw_detail.rowcount()
for i = rowcount to 1 step -1
//delrow = rowcount + 1 - i
quantity = dw_detail.getitemdecimal(i, 'quantity')
retprice = dw_detail.getitemdecimal(i, 'price')
itemcode = dw_detail.getitemstring(i, 'chargecode')
if itemcode = '' or isnull(itemcode) or isnull(quantity) or quantity = 0 or isnull(retprice) then
dw_detail.deleterow(i)
end if
next
------解决方案--------------------
这样肯定好用的
------解决方案--------------------
正反肯定都没问题呢,报什么错呀