Allow Only Text Input

What is the code to allow only text to be inputted into a text box


Also what would be the could to only allow numeric values, and another to allow only dates (dd/mm/yyyy)

Any help appreciated.


Answer this question

Allow Only Text Input

  • Tone Southerland

    Ok, thanks for help. This is very useful
  • AeQuitaZ

    hi,

    you can use keypress event handler to get that ,

    if not char.isnumber(e.keycode) or not e.keycode = '\' then

    e.handle = true

    messagebox.show("plz enter date only")

    end if

    you can use isletter in the other case

    hope this helps



  • Blue Stone Post

    Have a look below for the text box:

    http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx

    and for the date try erither: MaskedTextBox, DateTimePicker control or the keypress event


  • Allow Only Text Input