Only insert digit in textbox in vb.net [Resolved]

Posted by Amulya under VB.NET on 7/31/2013 | Points: 10 | Views : 1214 | Status : [Member] | Replies : 2
How to insert Only insert digit in textbox in vb.net




Responses

Posted by: Satyapriyanayak on: 7/31/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Public Class Form1


Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsDigit(e.KeyChar) Then
ElseIf e.KeyChar = ControlChars.Back Then
Else
e.Handled = True
End If
End Sub
End Class


If this post helps you mark it as answer
Thanks

Amulya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/1/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
The following URL will give you the NumericTextBox
http://msdn.microsoft.com/en-us/library/ms229644(v=vs.80).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

1) Create new NumericTextBox class
2) add the above class to you r project

This link will give you the logic to enter digits along with dots ( for decimal input)
http://stackoverflow.com/questions/11246198/how-to-only-allow-digits-and-dots-in-textbox-vb-net


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Amulya, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response