以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]同一段代码,部分计算机闪退,太恼火了 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=158367) |
||||
-- 作者:一丁 -- 发布时间:2020/11/17 20:07:00 -- [求助]同一段代码,部分计算机闪退,太恼火了 在一个表的DataColChanged事件中有如下代码: If e.DataCol.Name = "起始日期" Or e.DataCol.Name = "截止日期" If ( Not e.DataRow("起始日期") = Nothing) And (Not e.DataRow("截止日期") = Nothing) Then Dim dt1 As Date = e.DataRow("起始日期") Dim dt2 As Date = e.DataRow("截止日期") Dim y,m,d As Integer DateYMD(dt1,dt2,y,m,d) e.DataRow("执行月数") = y *12 + m +1 Else e.DataRow("执行月数") = Nothing End If End If 部分计算机能正常执行,部分计算机在起始日期或截止日期发生改变时,程序就闪退,不知道是什么原因,头都大了!! 望版主及各路高手帮忙分析一下,谢谢!!! 执行月数字段为Integer型字段,操作系统有win7,win10各种版本都有。 |
||||
-- 作者:有点蓝 -- 发布时间:2020/11/17 20:13:00 -- DataColChanged事件还有没有其他代码?有没有和这3个列有关的表达式列? |
||||
-- 作者:一丁 -- 发布时间:2020/11/17 20:25:00 -- 上一段代码后紧接着是这样的代码,也就是如果月数为空,就不再继续后边的代码 If e.DataRow("执行月数") = Nothing Return End If 如果把红色的这一段代码注释掉,所有的计算机都不会闪退,也不报错。 If e.DataCol.Name = "起始日期" Or e.DataCol.Name = "截止日期" If ( Not e.DataRow("起始日期") = Nothing) And (Not e.DataRow("截止日期") = Nothing) Then Dim dt1 As Date = e.DataRow("起始日期") Dim dt2 As Date = e.DataRow("截止日期") Dim y,m,d As Integer DateYMD(dt1,dt2,y,m,d) e.DataRow("执行月数") = y *12 + m +1 Else e.DataRow("执行月数") = Nothing End If End If |
||||
-- 作者:一丁 -- 发布时间:2020/11/17 20:26:00 -- 所以,基本上很确定,闪退就是这一段代码 |
||||
-- 作者:有点蓝 -- 发布时间:2020/11/17 20:27:00 -- DataColChanged事件完整代码发上来呀 |
||||
-- 作者:一丁 -- 发布时间:2020/11/17 20:38:00 -- 字数限制,只能附件,谢谢
|
||||
-- 作者:有点蓝 -- 发布时间:2020/11/17 22:00:00 -- 很多代码都没有判断列名:http://www.foxtable.com/webhelp/topics/1522.htm 导致死循环
|