以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]关于表格结果判定问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=83399) |
||||
-- 作者:benwong2013 -- 发布时间:2016/4/8 9:00:00 -- [求助]关于表格结果判定问题 如下图,在表格中有“项目名称、标准要求、结果、判定” 1. 希望在结果填入之后,能根据标准要求的数值范围进行判定,若不是数值则不进行判定; 2. 数值范围有大于等于、小于等于、小于、大于、或一定的数值区间,能根据结果进行判定; 请问是直接可以处理,还是要分根据不同条件来填写在DataColChanged 增加代码来分别判定? [此贴子已经被作者于2016/4/8 9:09:35编辑过]
|
||||
-- 作者:大红袍 -- 发布时间:2016/4/8 9:34:00 -- 汗
|
||||
-- 作者:benwong2013 -- 发布时间:2016/4/19 9:10:00 -- 此主题相关图片如下:1.png Select Case e.DataCol.name Case "标准", "结果" Dim str As String = e.DataRow("标准") If str Is Nothing OrElse e.DataRow.IsNull("结果") Then e.DataRow("判定") = Nothing Else Dim fhs() As String = {">", "=", "<"} Dim ary() As String For Each f As String In fhs If str.Indexof(f) Then If str.IndexOf("x") >= 0 Then ary = str.split("x") Else ary = new String() {str} End If str = "pass" For Each s As String In ary Dim flag = False For Each fh As String In fhs If s.IndexOf(fh) = s.Length-1 Then flag = True End If Next Dim ns As String = iif(flag=True, s & e.DataRow("结果"), e.DataRow("结果") & s) Functions.remove("函数") Dim Code As String Code = "return " & ns Functions.Add("函数",Code) Functions.Complie() Dim result = Functions.Execute("函数") If result = False Then str = "fail" End If Next e.DataRow("判定") = str Exit For End If Next End If End Select 以上代码看了好久还是有点不明白,但如果直接套用,会发现若标准列为空,若结果有输入的时候,其判定还是显示pass而不是为空,我将其修改为IF的方式不用case的控制流程,还是不行;
|
||||
-- 作者:大红袍 -- 发布时间:2016/4/19 9:21:00 -- Select Case e.DataCol.name Case "标准", "结果" Dim str As String = e.DataRow("标准") If str = Nothing OrElse e.DataRow.IsNull("结果") Then e.DataRow("判定") = Nothing Else Dim fhs() As String = {">", "=", "<"} Dim ary() As String For Each f As String In fhs If str.Indexof(f) Then If str.IndexOf("x") >= 0 Then ary = str.split("x") Else ary = new String() {str} End If str = "pass" For Each s As String In ary Dim flag = False For Each fh As String In fhs If s.IndexOf(fh) = s.Length-1 Then flag = True End If Next Dim ns As String = iif(flag=True, s & e.DataRow("结果"), e.DataRow("结果") & s) Functions.remove("函数") Dim Code As String Code = "return " & ns Functions.Add("函数",Code) Functions.Complie() Dim result = Functions.Execute("函数") If result = False Then str = "fail" End If Next e.DataRow("判定") = str Exit For End If Next End If End Select |