以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  未将对象引用设置到对象的实例。  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=178292)

--  作者:i4whylg
--  发布时间:2022/6/28 15:24:00
--  未将对象引用设置到对象的实例。
我要在原始列类似于114.3/114.3/88.9/88.9/60.3的字符串找出最大的数字,填写在“最大”列


If e.DataCol.Name = "原始" Then 
    If e.DataRow.IsNull("原始") Then 
        e.DataRow("最大") = Nothing 
    Else
        Dim Multi As String = e.NewValue
        If Multi.Contains("/") Then
            Dim Values() As String = Multi.split("/")
            Dim zdz() As Double 
            For i As Integer = 0 To Values.length - 1
                zdz(i) = Values(i)
            Next
            e.DataRow("最大") = zdz.max
        End If
        
    End If
End If

一直提示:
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2022.1.30.2
错误所在事件:表,表A, DataColChanged
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。
[此贴子已经被作者于2022/6/28 15:24:34编辑过]

--  作者:有点蓝
--  发布时间:2022/6/28 15:36:00
--  
    Else
        Dim Multi As String = e.NewValue
dim max as double = 0
        If Multi.Contains("/") Then
            Dim Values() As String = Multi.split("/")
            For i As Integer = 0 To Values.length - 1
if max < Values(i) then
max = Values(i)
end if
            Next
else
max = e.NewValue
        End If
      e.DataRow("最大") = max
    End If

--  作者:811233895
--  发布时间:2022/6/28 15:36:00
--  
If e.DataCol.Name = "原始" Then 
    If e.DataRow.IsNull("原始") Then 
        e.DataRow("最大") = Nothing 
    Else
        Dim Multi As String = e.NewValue
        If Multi.Contains("/") Then
            Dim Values() As String = Multi.split("/")
            e.DataRow("最大") = Values.max
        End If
        
    End If
End If

--  作者:有点蓝
--  发布时间:2022/6/28 15:41:00
--  
3楼的用法不对,因为是字符串拆分的,字符串是按照从左到右比较的,这样Values.max最大的是88.9,而不是114.3
--  作者:i4whylg
--  发布时间:2022/6/28 15:43:00
--  
感谢有点蓝老师,可以了,3楼的方法不能用来比较字符串
[此贴子已经被作者于2022/6/28 15:44:07编辑过]