控件TextBox21的TextChanged事件代码
Dim tx As WinForm.TextBox = e.Sender
Dim nf As Integer = e.Form.Controls("TextBox21").text
If tx.Text.Length = 4 And nf > 1623 Then
Dim fdr As DataRow = DataTables("年号").Find("年份 = '" & nf & "'")
If fdr Is Nothing And nf < 1624 Then
e.Form.Controls("TextBox22").text = Nothing
Else
e.Form.Controls("TextBox22").text = fdr("年号")
End If
Else
e.Form.Controls("TextBox22").text = Nothing
End If
当TextBox21为空时出错,请问如何修改代码?谢谢!!
此主题相关图片如下:屏幕截图 2024-09-30 101527.png
[此贴子已经被作者于2024/9/30 11:29:21编辑过]
Dim nf As Integer = val(e.Sender.text)
e.Form.Controls("TextBox22").text = Nothing
If nf > 1623 Then
Dim fdr As DataRow = DataTables("年号").Find("年份 = '" & nf & "'")
If fdr Isnot Nothing Then
e.Form.Controls("TextBox22").text = fdr("年号")
End If
End If