|
-
Oct 9th, 2002, 09:31 AM
#1
Thread Starter
New Member
Validate pasted data
I am tring to validate the data being pasted into a text field before it is written to the field.
I need to disable the paste of non numeric characters even if pasted from the clipboard.
I already disabled the Ctrl+V option, but I still have the paste option in the right-click menu opened for the textbox.
Thanks
-
Oct 9th, 2002, 10:05 AM
#2
Addicted Member
I suppose you could scan through the textbox and see if any of the characters are not numbers on the textchanged event. Then either remove the the letters/non numeric characters or take everything out of the textbox.
example:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim s As String
Dim c As Char
For Each c In TextBox1.Text
If c = "1" Or c = "2" Or c = "3" Or c = "4" Or c = "5" Or c = "6" Or c = "7" Or c = "8" Or c = "9" Or c = "0" Then
s &= c
End If
Next
TextBox1.Text = s
End Sub
Jeremy
Last edited by Jeremy Martin; Oct 9th, 2002 at 10:09 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|