Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Convert.ToInt32(e.KeyChar) = 22 Then
'The user pressed Ctrl+V.
Dim cbData As IDataObject = Clipboard.GetDataObject
'Check whether the clipboard contains text.
If cbData.GetDataPresent(DataFormats.Text) Then
'The clipboard contains text that can be pasted.
Dim cbString As String = CType(cbData.GetData(DataFormats.Text), String)
'Check that every character is a letter.
For i As Integer = 0 To cbString.Length - 1 Step 1
If Not Char.IsLetter(cbString.Chars(i)) Then
'Do not accept the clipboard data.
e.Handled = True
'Alert the user that the character has been rejected.
Beep()
Return
End If
Next
End If
ElseIf Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsLetter(e.KeyChar) Then
'Do not accept the character.
e.Handled = True
'Alert the user that the character has been rejected.
Beep()
End If
End Sub