用验证控件控制TextArea里面只能输入数字和逗号
在.NET里面实现“用验证控件控制TextArea里面只能输入数字和逗号”要用正则表达式急急急!!!...
在.NET里面实现“用验证控件控制TextArea里面只能输入数字和逗号”要用正则表达式
急急急!!! 展开
急急急!!! 展开
3个回答
展开全部
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim re As New Regex("\d|,")
Dim text As String = e.KeyChar
Dim mc As MatchCollection = re.Matches(text)
If mc.Count = 0 Then
e.Handled = True
End If
End Sub
End Class
Public Class Form1
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim re As New Regex("\d|,")
Dim text As String = e.KeyChar
Dim mc As MatchCollection = re.Matches(text)
If mc.Count = 0 Then
e.Handled = True
End If
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询