Foxtable(狐表)用户栏目专家坐堂 → 狐爸,优化帮助文件中的一段代码。


  共有8741人关注过本帖树形打印复制链接

主题:狐爸,优化帮助文件中的一段代码。

帅哥哟,离线,有人找我吗?
Fotable
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1015 积分:6979 威望:0 精华:0 注册:2012/8/1 18:41:00
狐爸,优化帮助文件中的一段代码。  发帖心情 Post By:2012/10/24 19:39:00 [只看该作者]

在帮助文件中关于beforeaddfile事件

http://www.foxtable.com/help/topics/2638.htm

 

If e.DataCol.name = "文件" Then
    If e.DataRow.IsNull(
"用户") = False
        Dim pth As String = "c:\data\" & e.DataRow(
"用户")
        If FileSys.DirectoryExists(pth) Then
            e.Path = pth
        Else
            e.path  = "c:\data"
        End If
    Else
        e.path = "c:\data"
   
End If
End
If

 

这段代码有点繁琐,可以优化代码为:

If e.DataCol.name = "文件" Then

    e.path  = "c:\data"

    If not e.DataRow.IsNull("用户") andalso FileSys.DirectoryExists(e.path & e.DataRow("用户")) then
        
    e.Path = e.path & e.DataRow("用户")
    End If

End If

[此贴子已经被作者于2012-10-24 19:41:37编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251048 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/10/24 21:13:00 [只看该作者]

嗯,你写得不错。

 回到顶部