此主题相关图片如下: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的控制流程,还是不行;