简体   繁体   中英

count characters in a masked textbox for check

I am using a masked TextBox, and I would like to check the input (total characters must be 14), is there a property for the masked TextBox to handle this or should I use a function? Can someone help me?

You should be able to do it with this:

' Remove spaces
Dim textNoSpaces As String = TextBox1.Text.Replace(" ", "")

If textNoSpaces.Length <> 14 Then
    ' Do something here
Else
    ' Do something else, if desired
End If

The masking is a display thing, it has nothing to do with the actual string entered by the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM