Intercept the Paste command in VB.NET

10 pts.
Tags:
Development
VB.NET
I wrote a function that allows only numbers to be entered into the field, which is accessed through the KeyDown event. It runs as follows: Public Sub NumbersOnly(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) If (Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57) And Asc(e.KeyChar) <> 46 And Asc(e.KeyChar) <> 8 Then e.Handled = True End If End Sub But then I realized that Pasting is impossible, so I added this clause: If e.Control Then If e.KeyCode = Keys.V Then ***EVALUATE EACH CHARACTER**** End If End If But, this only helps for the Ctrl+V key press. What can I do to do the same to the paste command in the popup menu?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try adding the function to the OnChange event or the MouseClick event (I think that both exist).

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: