Computing.Net > Forums > Programming > Textbox only for numbers vb.net

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Textbox only for numbers vb.net

Reply to Message Icon

Name: Grusomhat
Date: April 7, 2006 at 14:33:19 Pacific
OS: XP
CPU/Ram: AMD 64+ , 1gb
Product: Packard Bell
Comment:

Quick question
Is there a way in vb.net to make a textbox only accept integers without having to have a whole lot of If statements.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: April 7, 2006 at 15:02:56 Pacific
Reply:

Use the IsNumeric(expression)command.

However this is not foolproof as it also excepts commas, periods and other punctuation marks as being part of a number.

If you just want pure numbers use the Keypress event and test KeyAscii => 48 and =<57. Just one combined If statement.

Stuart


0

Response Number 2
Name: Grusomhat
Date: April 7, 2006 at 15:57:48 Pacific
Reply:

Hey Stuart
Thanks I will go with the IsNumeric command with keypress event. Thanks for your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Textbox only for numbers vb.net

Question Regarding VB.net and C# www.computing.net/answers/programming/question-regarding-vbnet-and-c/3580.html

VB.net project ideas needed www.computing.net/answers/programming/vbnet-project-ideas-needed/14113.html

textbox in VB.net www.computing.net/answers/programming/textbox-in-vbnet/16962.html