Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
TextBox_KeyDown KeyCode, Shift
End Sub
Sub TextBox_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim chaineclip As String
Select Case KeyCode
Case 49 To 57: KeyCode = KeyCode + 48 ' de 1 à 9 haut du clavier
Case 97 To 105 'juste pour garder le pavé
Case 86 ' touche "V"
If Shift = 2 Then 'si touche control appuyée
Dim objdata As New DataObject
With objdata
.GetFromClipboard: chaineclip = .GetText
If chaineclip Like "*[a-z|0]*" Then
.SetText "": chaineclip = "":
Else
TextBox1.Value = chaineclip: .SetText "":
End If
End With
End If
KeyCode = 0
Case 8: 'juste pour garder la touche back dispo
Case 46: 'juste pour garder la touche suppr dispo
Case Else: KeyCode = 0 ' toute les autres touches bloquées
End Select
End Sub