|  |  | 
              
              | 
                  | Title | Restrict paste in a TextBox's context menu | 
|---|
 | Keywords | TextBox, right click, popup, context menu | 
|---|
 | Categories | Controls | 
|---|
 |  | 
 |  | By Ariel Canievsky. 
To make sure that the type of data in the Clipboard is or not a numeric value. Test this:
 
     If Val(Clipboard.GetText) = 0 Then Clipboard.Clear 
And then, if you don't wanna loose the data of the Clipboard, first copy it to a variable and then give it back to the clipboard. The full code is liisted here:
               |  | 
 |  
                | Dim clp As String
Private Sub t_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    RetainClp
End Sub
Private Sub t_KeyPress(KeyAscii As Integer)
    If KeyAscii = 8 Then Exit Sub
    If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
Private Sub t_LostFocus()
    If Len(clp) > 0 Then Clipboard.SetText clp
End Sub
Sub RetainClp()
    If Val(Clipboard.GetText) = 0 Then
        clp = Clipboard.GetText
        Clipboard.Clear
    End If
End Sub |  -->|  |  |  |