Foxtable(狐表)用户栏目专家坐堂 → 判断窗口下的所有控件的.Value都不为空


  共有2700人关注过本帖树形打印复制链接

主题:判断窗口下的所有控件的.Value都不为空

帅哥哟,离线,有人找我吗?
WELOVEFOX
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:465 积分:3371 威望:0 精华:0 注册:2016/12/21 22:58:00
  发帖心情 Post By:2020/9/4 9:48:00 [显示全部帖子]

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编辑过]

 回到顶部