以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  Validating事件  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=133246)

--  作者:cd_tdh
--  发布时间:2019/4/10 15:37:00
--  Validating事件

老师,请教一下,控件的Validating事件用于校验身份证号码是否准确,不准确禁止移除控件,因为输入不准确的身份证号,也会提取到年龄,关闭窗口前没保存也不能关闭窗口,窗口有个取消按钮,这样写连取消按钮没法用了呢?

前序代码省略

If ValidPIN(d) = False Then
    MessageBox.Show("身份证号码输入有误,请仔细核对身份证号码","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    e.Cancel = True
Else
End If


--  作者:有点甜
--  发布时间:2019/4/10 16:59:00
--  

清空里面的字符即可。

 

If e.sender.text = "" Then

 

ElseIf ValidPIN(e.sender.text) = False Then
    MessageBox.Show("身份证号码输入有误,请仔细核对身份证号码","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    e.Cancel = True
End If