

|
DeathFox Member Posts: 57 From: Registered: 04-25-2006 |
How do I make it so that a textbox just accepts integers? And I dont wanna use a masked textbox, just a normal textbox |
|
bennythebear Member Posts: 1225 From: kentucky,usa Registered: 12-13-2003 |
in the textchanged event of the textbox you could put in some code to check to see if a letter or "." has been entered, and if so pop up an error message. i'm not really sure if that's what you're looking for, but there's prob'ly a better answer anyway, that's just a suggestion. ------------------ proverbs 25:7 www.gfa.org - Gospel for Asia www.persecution.com - Voice of the Martyrs |
|
DeathFox Member Posts: 57 From: Registered: 04-25-2006 |
But that method is too long, I need to compare all 24 letters if they exist on a textbox |
|
Tonnyx Member Posts: 140 From: Indiana, USA Registered: 08-02-2005 |
Can you use RegEx (regular expressions)? I did a google search, which yielded this: http://visualbasic.about.com/od/usingvbnet/l/blregexa.htm (see the bottom of the page). I'm sure there are probably better resources online, but I actually don't know any regex myself. I've just been around Clint enough to know what it does, and that it's very powerful. ------------------ |
bwoogie![]() Member Posts: 380 From: kansas usa Registered: 03-12-2005 |
quote: umm, dont you mean 26 letters? :| ------------------ |
|
samw3 Member Posts: 542 From: Toccoa, GA, USA Registered: 08-15-2006 |
I'm not sure how to do exactly it in VB, but the algorithm I would use would be in the key press event. Here is some pseudo-code: validChars = "0123456789" ------------------ |
|
Calin Member Posts: 358 From: Moldova Registered: 12-04-2006 |
As everyone else I don't know how the code would look in VB but you can try to convert the text in the textbox to an integer (in case that helps in C# that's Convert.ToInt32("string")). If the conversion fails the input string in not a valid number. That's how use to do it although there might be better way of solving the problem. |
|
DeathFox Member Posts: 57 From: Registered: 04-25-2006 |
But the program crasses when I do it, How can I detect if it failed? |