Foxtable(狐表)用户栏目专家坐堂 → 递归函数如何判断object is null?


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

主题:递归函数如何判断object is null?

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


加好友 发短信
等级:四尾狐 帖子:985 积分:8649 威望:0 精华:0 注册:2015/8/12 16:28:00
递归函数如何判断object is null?  发帖心情 Post By:2019/7/31 11:32:00 [只看该作者]

在制作treenode时,想制作一个类似教材里面《递归函数使用实例》的方法来做一个BOM表。

教材里面在执行自定义程序的时候,有传递一个treenode给程序的args(1)。这样是treeview里面最底层就是这个“全部”的节点。

而我如果不想传递一个基础节点给递归函数,让函数自己判断object是否是空,如果是空,自动在底层加node,否则就是在参数的node下面加。


我试过 Dim nd As WinForm.TreeNode=args(1)
if nd.name="" then
.....

当传递一个空的args给程序后,nd.name会报错。
请问如何判断object 是空?


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


加好友 发短信
等级:超级版主 帖子:108113 积分:549982 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/7/31 11:48:00 [只看该作者]

Dim nd As WinForm.TreeNode=args(1)
if nd is nothing then
msgbox("空")
end if

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


加好友 发短信
等级:四尾狐 帖子:985 积分:8649 威望:0 精华:0 注册:2015/8/12 16:28:00
  发帖心情 Post By:2019/8/7 11:38:00 [只看该作者]

我这样做报错了。
Exception has been thrown by the target of an invocation.
Index was outside the bounds of the array.


我的自定义程序是:
Dim lbl As WinForm.NumericComboBox
Dim lblname As WinForm.TreeNode =args(0)
Dim tv As WinForm.TreeView =args(1)
If tv IsNot Nothing Then
   。。。。。

    Return Nothing
Else
MessageBox.Show(1)  这段代码都不能执行到。
    Forms("new_MO").RemoveControl(lblname.name)
    Return Nothing

End If

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


加好友 发短信
等级:四尾狐 帖子:985 积分:8649 威望:0 精华:0 注册:2015/8/12 16:28:00
  发帖心情 Post By:2019/8/7 11:40:00 [只看该作者]

OK了,
外面的引用要这样写。Functions.Execute("addlbl",e.node,Nothing)才可以

 回到顶部