For Each c As WinForm.Control In e.Form.Controls
If Typeof c Is WinForm.TextBox Then '判断控件是否是文本框
Dim t As WinForm.TextBox = c '使用特定类型的变量引用控件
If t.Value = Nothing Then
MessageBox.Show("文本控件不能为空!")
t.Select()
Return
End If
End If
Next
For Each c As WinForm.Control In e.Form.Controls
If Typeof c Is WinForm.ComboBox Then '判断控件是否是文本框
Dim t As WinForm.ComboBox = c '使用特定类型的变量引用控件
If t.Value = Nothing Then
MessageBox.Show("组合框不能为空!")
t.Select()
Return
End If
End If
Next
For Each c As WinForm.Control In e.Form.Controls
If Typeof c Is WinForm.DateTimePicker Then '判断控件是否是文本框
Dim t As WinForm.DateTimePicker = c '使用特定类型的变量引用控件
If t.Value = Nothing Then
MessageBox.Show("日期框不能为空!")
t.Select()
Return
End If
End If
Next
[此贴子已经被作者于2020/9/4 9:48:38编辑过]