我有一个textbox
,我希望它只接受"xxx_yyy"
格式的输入,'xxx'
只能包含字母(az和AZ)和特殊字符'yyy'
1}}只能包含数字(0-9)。怎么做?
答案 0 :(得分:0)
嗯,这就是那个例子
在表单上删除 MaskedTextBox 元素,然后双击表单以创建 Form1_Load()事件并查看代码
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Create a mask we want to use. In your case it will be "LLL_000"
' Here LLL is 3 ASCI letters. Equivalent to [a-zA-Z] in regular expressions.
' _ delimiter
' And 000 is 3 digits in range 0-9
Dim mask As String = "LLL_000"
' Assign the mask to MaskedTextBox object
MaskedTextBox1.Mask = mask
End Sub
您可以通过Property Editor设置遮罩值。您还需要一个带有MaskedTextbox的描述标签,否则用户会感到困惑。