以文本方式查看主题

-  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=171837)

--  作者:aaa1234
--  发布时间:2021/9/11 13:40:00
--  计时器未将对象引入实例
Dim dr As Row = Tables("Table_3").Current
If dr("状态")="跟进中"
Dim d As Date = cdate(dr("记录日期")).adddays(val(e.Form.Controls("TextBox6").text)) 
Dim dt As Date =  format(d,"yyyy-MM-dd 23:59:59")
Dim t As TimeSpan = dt - Date.Today     \'计算现在离今天的24时整还差多少时间
e.Form.Controls("Label29").Text = "剩余" & t.Days & "天" & t.Hours & "小时" & t.Minutes & "分" & t.Seconds & "秒"

Dim Lbl As WinForm.Label = e.Form.Controls("Label29")
If Lbl.ForeColor = Color.Red Then
    Lbl.ForeColor = Color.Black
Else
    Lbl.ForeColor = Color.Red
End If
Else
e.Form.Controls("Label29").text =""
End If
图片点击可在新窗口打开查看此主题相关图片如下:wechat 圖片_20210911133827.png
图片点击可在新窗口打开查看

--  作者:aaa1234
--  发布时间:2021/9/11 13:46:00
--  
老师我的代码是不是有问题,我刚刚发的就是录入窗口的timerTick的代码
--  作者:有点蓝
--  发布时间:2021/9/11 13:52:00
--  
参考:http://www.foxtable.com/webhelp/topics/0445.htm

Dim dr As Row = Tables("Table_3").Current
if dr is nothing then return

--  作者:aaa1234
--  发布时间:2021/9/11 13:58:00
--  
所以我要加这么防止他返回nothing是吧if dr is nothing then return
--  作者:aaa1234
--  发布时间:2021/9/11 14:05:00
--  
Dim dr As Row = Tables("Table_3").Current
If dr Is Nothing Then Return
If dr("状态")="跟进中"
Dim d As Date = cdate(dr("记录日期")).adddays(val(e.Form.Controls("TextBox6").text)) 
Dim dt As Date =  format(d,"yyyy-MM-dd 23:59:59")
Dim t As TimeSpan = dt - Date.Today     \'计算现在离今天的24时整还差多少时间
e.Form.Controls("Label29").Text = "剩余" & t.Days & "天" & t.Hours & "小时" & t.Minutes & "分" & t.Seconds & "秒"

Dim Lbl As WinForm.Label = e.Form.Controls("Label29")
If Lbl.ForeColor = Color.Red Then
    Lbl.ForeColor = Color.Black
Else
    Lbl.ForeColor = Color.Red
End If
Else
e.Form.Controls("Label29").text =""
End If                         这样可以吗
[此贴子已经被作者于2021/9/11 14:04:50编辑过]

--  作者:有点蓝
--  发布时间:2021/9/11 14:16:00
--  
测试,有问题再说问题