以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 求助代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=170554) |
-- 作者:shried -- 发布时间:2021/7/30 10:04:00 -- 求助代码 各位大神、老师: 我运用表事件进行编程时: Dim dr2 As Date= Date.Today Dim dr1 As Date= e.DataRow("失效日") If e.DataCol.Name ="失效日" Then Dim y2 As Integer= dr2.Year Dim y1 As Integer= dr1.Year If y1>y2 Then e.DataRow("是否有效")=True If y1<y2 Then e.DataRow("是否有效")=False Else Dim m2 As Integer= dr2.Month Dim m1 As Integer= dr1.Month If m1>m2 Then e.DataRow("是否有效")=True If m1<m2 Then e.DataRow("是否有效")=False Else Dim d2 As Integer= dr2.Day Dim d1 As Integer= dr1.Day If d1>=d2 Then e.DataRow("是否有效")=True If d1<d2 Then e.DataRow("是否有效")=False End If End If End If End If End If End If End If 做一个客户列表的有效性,但是代码好像不管输入日期是不是当前日期前或者后,都是有效。 |
-- 作者:有点蓝 -- 发布时间:2021/7/30 10:13:00 -- 日期可以直接比较的,没有必要按年月日逐个比较,3句代码即可 If e.DataCol.Name ="失效日" Then e.DataRow("是否有效")=(e.DataRow("失效日") > Date.Today) End If |
-- 作者:shried -- 发布时间:2021/7/30 15:14:00 -- 已解决,感谢老师。 |