vb.net里怎么限制textbox输入的字符?
1个回答
展开全部
Dim str As String
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
Dim d As Double
If Double.TryParse(TextBox1.Text, d) Or TextBox1.Text = "-" OrTextBox1.Text.Trim() = "" Then
Str = TextBox1.Text
Else
TextBox1.Text = str
TextBox1.SelectionStart = TextBox1.Text.Length
TextBox1.Focus()
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询