仅接受数值的文本框。 我有一个银行帐号的文本框。现在我希望此文本框仅接受数值。
答案 0 :(得分:0)
`Private Sub Data_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Data.KeyPress
If (Not e.KeyChar = ChrW(Keys.Back) And ("0123456789.").IndexOf(e.KeyChar) = -1) Or (e.KeyChar = "." And Data.Text.ToCharArray().Count(Function(c) c = ".") > 0) Then
e.Handled = True
End If
End Sub
`