以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 代码无效 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=113285) |
-- 作者:edisontsui -- 发布时间:2018/1/12 15:08:00 -- 代码无效 如下这段代码不起作用: If e.DataCol.Name = "吋长" Then If e.DataRow("直弯") = "" If e.NewValue IsNot Nothing MessageBox.Show("直弯一栏必须填写<直身/弯头/珠直/珠弯>字样!", "提示") e.Cancel = True End If End If End If 但下面的代码是有效的: If e.DataCol.Name = "确认" Then If e.DataRow("直弯") = "" If e.NewValue = True MessageBox.Show("直弯一栏必须填写<直身/弯头/珠直/珠弯>字样!", "提示") e.Cancel = True End If End If End If 这是为什么?(备注:吋长为单精度小数型,直弯为字符型,确认为逻辑型)。谢谢。
|
-- 作者:有点甜 -- 发布时间:2018/1/12 15:34:00 -- 首先,datacolchanging事件,是你输入值以后,离开单元格,才会触发的。
然后,如果你希望输入的过程中立马提示,你要在ChangeEdit事件写代码。
如果要在输入之前提示,你要在startEdit事件写代码。 [此贴子已经被作者于2018/1/12 15:35:20编辑过]
|
-- 作者:edisontsui -- 发布时间:2018/1/12 15:52:00 -- 但是上面第一段代码,我输入一个值之后离开单元格时,不会触发提示啊。而第二段代码则能够正常提示。 |
-- 作者:有点甜 -- 发布时间:2018/1/12 16:01:00 -- 代码肯定没问题。你列【吋长】是表达式列?要改成数据列。 |
-- 作者:edisontsui -- 发布时间:2018/1/12 16:50:00 -- 【吋长】是数据列,但是在datacolchanged 里面有如下代码,是否有冲突? If e.DataCol.name = "吋长度" e.DataRow("毫米长度") = Math.round(e.DataRow("吋长度") * 25.4,2) End If If e.DataCol.name = "毫米长度" e.DataRow("吋长度") = Math.round(e.DataRow("毫米长度") / 25.4,2) End If
|
-- 作者:有点甜 -- 发布时间:2018/1/12 16:52:00 -- 你尝试这样写,看弹出什么
msgbox(e.datacol.name) If e.DataCol.Name = "吋长" Then
msgbox(e.DataRow("直弯"))
If e.DataRow("直弯") = ""
msgbox(e.newvalue)
If e.NewValue = Nothing
msgbox(3)
MessageBox.Show("直弯一栏必须填写<直身/弯头/珠直/珠弯>字样!", "提示")
e.Cancel = True
End If
End If
End If
|