以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  怎样写代码使textbox,只可以唯一写5个字符才合法  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=79721)

--  作者:limit_1982
--  发布时间:2016/1/7 21:39:00
--  怎样写代码使textbox,只可以唯一写5个字符才合法

谢谢

像身份证必须写18位,一样的

[此贴子已经被作者于2016/1/7 21:41:51编辑过]

--  作者:大红袍
--  发布时间:2016/1/7 21:44:00
--  
具体指什么?5个字符?还必须不重复?
--  作者:大红袍
--  发布时间:2016/1/7 21:52:00
--  

Validating事件

 

If e.sender.text > "" Then
    If e.sender.text.length <> 5 Then
        msgbox("不是5位")
        e.cancel = True
    Else
        For i As Integer = 0 To e.Sender.text.length-1
            For j As Integer = i+1 To e.sender.text.length-1
                If e.sender.Text(i) = e.sender.Text(j) Then
                    msgbox(i & "位 和 " & j & "位重复")
                    e.cancel = True
                    Return
                End If
            Next
        Next
    End If
End If


--  作者:limit_1982
--  发布时间:2016/1/8 0:13:00
--  

可以重复的

5个char 就可以了,多也不行少也不行咯


--  作者:limit_1982
--  发布时间:2016/1/8 0:20:00
--  
If e.sender.text > "" Then
    If e.sender.text.length <> 5 Then
        msgbox("不是合法")
        e.cancel = True
 End If
End If