改成
Dim txt As String = e.Sender.Text
'If txt <> Nothing Then
If txt > "" Then
If txt.Length > 20 Then
e.Sender.Error = "政治面貌长度不允许超过20"
Else
e.Sender.Text= txt.Replace(" ","")
If e.Form.Controls("politicalStatus").Value ="中共党员" Then
If e.Form.Controls("partyTime").Value ="" Then
e.Form.Controls("PartyTime").Error= "入党时间不允许为空"
Else
e.Form.Controls("PartyTime").Error= ""
Dim d As Date = e.Form.Controls("partyTime").text
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
msgbox(d)
If y < 0 Then
e.Form.Controls("partyStanding").Value = 0
End If
e.Form.Controls("partyStanding").Value = y
e.Form.Controls("partyStanding").WriteValue
End If
End If
End If
End If