Protected Overrides Sub OnKeypress(ByVal e As System.Windows.Forms.KeyPressEventArgs) '---protected modifier allows sub to be used in classes derived from this one and be used in ' the assembly of this project but not other assemblies Select Case m_LegalKeys Case KeystrokeOption.All 'allow any keystroke e.Handled = False 'don't block Case KeystrokeOption.LettersOnly 'lower or upper case letters & backspace key If UCase(e.KeyChar) >= "A" And UCase(e.KeyChar) <= "Z" _ Or e.KeyChar = ControlChars.Back _ Or ConsoleKey.Spacebar Then 'space e.Handled = False Else e.Handled = True 'block it End If Case KeystrokeOption.NumbersOnly 'numbers only & "." & Backspace key If (e.KeyChar >= "0" And e.KeyChar <= "9") _ Or e.KeyChar = "." _ Or e.KeyChar = ControlChars.Back Then e.Handled = False Else e.Handled = True 'block it End If Case Else e.Handled = True End Select End Sub