以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于时间类型的判空  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=124666)

--  作者:susu312
--  发布时间:2018/9/11 16:45:00
--  关于时间类型的判空

Dim txt As Date = e.Sender.Text
If txt <> Nothing  Then
      Dim d As Date = e.Form.Controls("partyTime").Value
      Dim y As Integer = d.year
      If format(d, "MMdd") <= Format(Date.Today, "MMdd") Then
           y = Date.Today.Year - y-1
      Else
           y = 0
      End If
      If y < 0 Then
             e.Form.Controls("partyStanding").Value = 0
      Else
             e.Form.Controls("partyStanding").Value = y
      End If
End If

 

老是,红色部分由问题么?从字符串“”到类型“Date”的转换无效。

[此贴子已经被作者于2018/9/11 16:46:09编辑过]

--  作者:有点甜
--  发布时间:2018/9/11 16:48:00
--  

Dim txt As Date = e.Sender.Text
If txt <> Nothing  Then

 

改成

 

Dim txt As String = e.Sender.Text
If txt <> Nothing Then