Disable Paste in A Numeric TextBox in VB.NET
- Private Sub ReadOnlyText(ByVal TxtBox As TextBox, Optional ByVal LockTextBox As Boolean = True)
 - Dim Clr As Color = TxtBox.BackColor
 - TxtBox.ReadOnly = LockTextBox
 - TxtBox.BackColor = Clr
 - End Sub
 
- Private Sub TextBoxNumeric_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBoxNumeric.MouseDown
 - ReadOnlyText(TextBoxNumeric)
 - End Sub
 
- Private Sub TextBoxNumeric_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBoxNumeric.KeyPress
 - Dim num As Char = e.KeyChar
 - ReadOnlyText(TextBoxNumeric, False)
 - e.Handled = False
 - Else
 - If TextBoxNumeric.Text.Contains(".") = True Then
 - e.Handled = True
 - Else
 - If num = Char.Parse(".") Then
 - ReadOnlyText(TextBoxNumeric, False)
 - e.Handled = False
 - Else
 - e.Handled = True
 - End If
 - End If
 - End If
 - End Sub
 
Output:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]
Visit and like my page on Facebook at: Bermz ISware Solutions
Subscribe at my YouTube Channel at: SerBermz
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.