vb.net - keypress to block letter/number on visual basic 2012 OOP method -


i want create register form using visual studio 2012 , sql server 2012.

the function want is: in windows form there 2 textbox:

  • if type number on first textbox program block number , allow letter

  • in second textbox program block letter , allow number

i heard use keypress.

what coding keypress that?

you need use ascii values :

if asc(e.keychar) <> 8     if asc(e.keychar) < 48 or asc(e.keychar) > 57         e.handled = true     end if end if 

in above example, use can enter numbers , can use backspace because function allow these ascii characters on keypress event.

8 -> backspace, 48-57 -> 0 9

similarly use ascii characters characters z ( both capital , small )


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -