Lost Password?


home | tags | Search | Feed
Tag >> C sharp

How to restrict a Textbox to only accept numbers in C#

Posted by: Johnnyboy in C sharp on

If you've ever wanted to restrict a texbox control to accept only numbers and not even allow the user to type characters this is how to do it.  Note that this code also allows the user to type non alpha characters like backspace.

private void txtNumber_KeyDown(object sender, KeyEventArgs e)
{
     if ((e.KeyValue > 0 && e.KeyValue < 31) || (e.KeyValue > 47 && e.KeyValue < 58))
    

Statistics

Members Today: 254
Members Online: 9
Users Online: 106
Total Users: 19,409
Total Threads: 11,265
Total Posts: 111,029
Newest Member: Apennydrype

Tutorials

Text Speecher.
Hello CodeCall .. Today i'm gonna show you how to make Text Speecher i think you understand ... something that you write ,click SPEECH and there will speech that what you write .. The Program i...


ArrayList - Simple version !
Hey guys, today I thought I could show you guys what you can do with ArrayList, java's own build in Array+List :>, the ArrayList is in general slower than normal Arrays if used in larger codes and sca...


Determinants Value
This is a very simple tutorial that shows how to create a simple program in VB6 to calculate the value of a determinant. First - Create 3 new forms. On form1 put a combo box and change its text ...