以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]单元格固定格式怎么约束?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=119225)

--  作者:新福星
--  发布时间:2018/5/20 20:36:00
--  [求助]单元格固定格式怎么约束?
某个单元格需要录入比例形式,例如 3:5:1。怎么约束录入的数据符合要求?谢谢
--  作者:有点甜
--  发布时间:2018/5/20 22:22:00
--  

方法一:掩码 http://www.foxtable.com/webhelp/scr/0047.htm

 

方法二:在validateEdit写正则表达式判断,如

 

Dim pattern As String = "^[1-9]\\d{3}-(0[1-9]|1[0-2]|[1-9])-(0[1-9]|[1-2][0-9]|3[0-1]|[1-9])$"
Dim txt As String= "2017-9-1" \'2017年9月
Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
If rgx.isMatch(txt) = False Then
    msgbox("请输入正确的日期!")
Else
    msgbox("正确")
End If