Click here to Skip to main content
15,899,935 members
Please Sign up or sign in to vote.
4.20/5 (2 votes)
See more:
I need help to create a text box that accepts only numbers and full stop in VB.Net.   It was easy in vb6 but in VB.Net I am really confused.   Can someone help me please,

Thank you.
Posted

1 solution

Private Sub txt1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt1.KeyPress<br />        Try<br />            If Not (Char.IsNumber(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then e.Handled = True<br />        Catch ex As Exception<br />            MsgBox(ex.ToString)<br />        End Try<br />    End Sub


 
Share this answer
 
Comments
tiagu 1-Apr-16 13:02pm    
Thank you Johan for your reply. I will use this. Sorry for the very very late reply.


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900