以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- 新增加一个判断,查找出来结果=0,就 = nothing (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=150714)
|
-- 作者:天宇科技
-- 发布时间:2020/6/5 15:22:00
-- 新增加一个判断,查找出来结果=0,就 = nothing
If e.DataCol.Name = "姓名" Then Dim nms() As String = {"教师ID","人员类别","岗位系数","提一个月"} If e.NewValue Is Nothing Then For Each nm As String In nms e.DataRow(nm) = Nothing Next Else Dim dr0 As DataRow dr0 = DataTables("设置").Find("[姓名] = \'" & e.NewValue & "\'") If dr0 IsNot Nothing For Each nm As String In nms e.DataRow(nm) = dr0(nm) Next End If End If End If
在这段代码中,我新增一个判断,当dr查出来的结果 "= 0 "时,我想让“e.NewValue” 为空。 应该怎样加呢
[此贴子已经被作者于2020/6/5 15:22:30编辑过]
|
-- 作者:有点蓝
-- 发布时间:2020/6/5 15:34:00
--
If dr0 IsNot Nothing For Each nm As String In nms e.DataRow(nm) = dr0(nm) Nextelse e.DataRow(e.DataCol.Name) = nothing End If
|
-- 作者:天宇科技
-- 发布时间:2020/6/5 15:53:00
--
这样应该是不行的
|
-- 作者:天宇科技
-- 发布时间:2020/6/5 15:55:00
--
Dim dr0 As DataRow dr0 = DataTables("设置").Find("[姓名] = \'" & e.NewValue & "\'") If dr0 IsNot Nothing For Each nm As String In nms e.DataRow(nm) = dr0(nm) Next End If
在这段代码中,查找出来可能是0,有可能是其他值,如果为0,就让e.NewValue =nothing ,如果是其他值,e.DataRow(nm) = dr0(nm) 你上面的代码,我试了,应该不行的。
|
-- 作者:有点蓝
-- 发布时间:2020/6/5 15:57:00
--
截图说明一下,什么地方为0?
|
-- 作者:天宇科技
-- 发布时间:2020/6/5 16:04:00
--
此主题相关图片如下:11.png
![dvubb 图片点击可在新窗口打开查看](UploadFile/2020-6/2020651624260649.png)
表格中为0的地方,就是在另一张中,没有数值,是空值,所以在这我查找出为的是0值。我想把0清除掉。不让他显示0值,不好看。下面这段代码和上面的是同样的原理。 If e.DataCol.Name = "姓名" Then Dim nms() As String = {"德","能","勤","教学常规","奖励加分"} If e.NewValue Is Nothing Then For Each nm As String In nms e.DataRow(nm) = Nothing Next Else Dim dr6 As DataRow dr6 = DataTables("德能勤常规奖励").Find("[姓名] = \'" & e.NewValue & "\'") If dr6 IsNot Nothing For Each nm As String In nms e.DataRow(nm) = dr6(nm) Next End If End If End If
|
-- 作者:天宇科技
-- 发布时间:2020/6/5 16:07:00
--
程版主帮我解决了。If e.DataCol.Name = "姓名" Then Dim nms() As String = {"教师ID","人员类别","岗位系数","提一个月"} If e.NewValue IsNot Nothing Then Dim dr0 As DataRow dr0 = DataTables("设置").Find("[姓名] = \'" & e.NewValue & "\'") If dr0 IsNot Nothing For Each nm As String In nms If nm = "提一个月" If dr0(nm) = 0 e.DataRow(nm) = Nothing Else e.DataRow(nm) = dr0(nm) End If Else e.DataRow(nm) = dr0(nm) End If Next End If End If End If
[此贴子已经被作者于2020/6/5 16:07:17编辑过]
|
-- 作者:程兴刚
-- 发布时间:2020/6/5 16:11:00
--
If e.DataCol.Name = "姓名" Then Dim nms() As String = {"教师ID","人员类别","岗位系数","提一个月"} If e.NewValue Is Nothing Then For Each nm As String In nms e.DataRow(nm) = Nothing Next Else Dim dr0 As DataRow dr0 = DataTables("设置").Find("[姓名] = \'" & e.NewValue & "\'") If dr0 IsNot Nothing For Each nm As String In nms If nm = "提一个月" If dr0(nm) = 0 e.DataRow(nm) = Nothing Else e.DataRow(nm) = dr0(nm) End If Else e.DataRow(nm) = dr0(nm) End If Next End If End If End If
|