How to filter textbox input to numeric only?

前端 未结 9 1540
耶瑟儿~
耶瑟儿~ 2020-12-21 13:37

How do I suppress all data except numeric?

This is not working on KeyDown():

If e.KeyData < Keys.D0 Or e.KeyData > Keys.D9 Then
          


        
9条回答
  •  没有蜡笔的小新
    2020-12-21 14:23

    This is another way to restrict number inputs into textbox . using KEYPRESS Events

    If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Not IsNumeric(e.KeyChar) Then MessageBox.Show("Only Numbers") e.Handled = True End If End Sub hope it helps ! thnks ..

提交回复
热议问题