Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共10 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:找不到“清零”贴子

1楼
xl 发表于:2009/12/24 9:59:00
我记得论坛上贺老师“清零”贴子(非表达式型或事件型),找不到了。
[此贴子已经被作者于2009-12-24 11:22:22编辑过]
2楼
yangming 发表于:2009/12/24 10:39:00
If e.DataCol.IsNumeric Then
    If
e.NewValue = 0 Then
        e.NewValue =
Nothing
    End
if
End
If

放在DataColChanging事件中
3楼
xl 发表于:2009/12/24 11:14:00

我这样设计,行吗?
For Each dr1 As DataRow In DataTables("表A").DataRows
    For Each dc As DataCol In DataTables("表A").DataCols
        if  dr1(dc)=0 then
            Dr1(dc)=nothing
        end if
    Next
Next

4楼
czy 发表于:2009/12/24 11:15:00
以下是引用xl在2009-12-24 11:14:00的发言:

我这样设计,行吗?
For Each dr1 As DataRow In DataTables("表A").DataRows
    For Each dc As DataCol In DataTables("表A").DataCols
        if  dr1(dc)=0 then
            Dr1(dc)=nothing
        end if
    Next
Next


不行,最起码你得用IsNumeric判断某列是不是数值型才可以。

5楼
xl 发表于:2009/12/24 11:19:00
有问题,只有“0”是“双精度小数”时才能清零,若为其它类型如字符型怎么清零呢?
6楼
yangming 发表于:2009/12/24 11:22:00
字符型只能是为空啊
7楼
czy 发表于:2009/12/24 11:50:00
以下是引用xl在2009-12-24 11:19:00的发言:
有问题,只有“0”是“双精度小数”时才能清零,若为其它类型如字符型怎么清零呢?


那你就多加一个判断。

8楼
czy 发表于:2009/12/24 11:51:00
这样应该也行吧?

For Each dr1 As DataRow In DataTables("表A").DataRows
    For Each dc As DataCol In DataTables("表A").DataCols
        If dc.IsNumeric Then
            if  dr1(dc) =0 then
                Dr1(dc)=nothing
            end if
        End If
        If dc.IsNumeric = False
            if  dr1(dc) = "0" then
                Dr1(dc)=nothing
            End If
        End If
    Next
Next
9楼
xl 发表于:2009/12/24 13:50:00
以下是引用czy在2009-12-24 11:51:00的发言:
这样应该也行吧?

For Each dr1 As DataRow In DataTables("表A").DataRows
    For Each dc As DataCol In DataTables("表A").DataCols
        If dc.IsNumeric Then
            if  dr1(dc) =0 then
                Dr1(dc)=nothing
            end if
        End If
        If dc.IsNumeric = False
            if  dr1(dc) = "0" then
                Dr1(dc)=nothing
            End If
        End If
    Next
Next

行。同样是“0”,也必须注意数值型和字符型之分。

10楼
xl 发表于:2009/12/24 13:53:00
谢谢两位版主!清零目目前有四种方法供选择(以上两种,下列还有两种):
http://www.foxtable.com/dispbbs.asp?BoardID=2&ID=784&replyID=&skin=1
共10 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.