Rss & SiteMap

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

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

标题:高手请看,代码能不能优化?

1楼
yanzhen2010 发表于:2011/8/4 23:52:00

高手请看,代码能不能优化?

If e.DataCol.Name = "拼音码" Then
    If e.DataRow("拼音码")IsNot Nothing Then
        e.DataRow("拼音码") =e.DataRow("拼音码").split(":")(0)
    End If
End If
If e.DataCol.Name = "拼音码" Then
    Dim lb As DataRow
    lb = DataTables("收费项目").Find("[拼音码] = '" & e.NewValue.split(":")(0) & "'")
    If lb IsNot Nothing Then
        e.DataRow("项目类别") = lb("项目类别")
        e.DataRow("项目名称") = lb("项目名称")
    Else
        MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("项目类别") = Nothing
        e.DataRow("项目名称") = Nothing
    End If
End If

2楼
e-png 发表于:2011/8/4 23:57:00

恭喜了,不需要再优化了。

3楼
狐狸爸爸 发表于:2011/8/5 7:47:00

可以省略一个if:

 

If e.DataCol.Name = "拼音码" Then
    If e.DataRow("拼音码")IsNot Nothing Then
        e.DataRow("拼音码") =e.DataRow("拼音码").split(":")(0)
    End If
    Dim lb As DataRow
    lb = DataTables("收费项目").Find("[拼音码] = '" & e.NewValue.split(":")(0) & "'")
    If lb IsNot Nothing Then
        e.DataRow("项目类别") = lb("项目类别")
        e.DataRow("项目名称") = lb("项目名称")
    Else
        MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("项目类别") = Nothing
        e.DataRow("项目名称") = Nothing
    End If
End If

共3 条记录, 每页显示 10 条, 页签: [1]

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

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