{"id":110,"date":"2009-12-29T13:13:17","date_gmt":"2009-12-29T12:13:17","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=110"},"modified":"2009-12-29T13:13:17","modified_gmt":"2009-12-29T12:13:17","slug":"make-a-textbox-that-accepts-only-numbers","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=110","title":{"rendered":"Make a Textbox that accepts only numbers"},"content":{"rendered":"<div id=\"wpshdo_1\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_1\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_1\"><\/a><a id=\"wpshat_1\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_1\"  onClick=\"javascript:wpsh_toggleBlock(1)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_code(1)\" title=\"Show code only\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png\" \/><\/a>&nbsp;<a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_print(1)\" title=\"Print code\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png\" \/><\/a>&nbsp;<a href=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_1\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"vbnet\" style=\"font-family:monospace;\"><span class=\"kw2\">Private<\/span> <span class=\"kw6\">Sub<\/span> TextBox1_KeyPress<span class=\"br0\">&#40;<\/span><span class=\"kw2\">ByVal<\/span> sender <span class=\"kw2\">As<\/span> <span class=\"kw4\">Object<\/span>, <span class=\"kw2\">ByVal<\/span> e <span class=\"kw2\">As<\/span> System.<span class=\"me1\">Windows<\/span>.<span class=\"me1\">Forms<\/span>.<span class=\"me1\">KeyPressEventArgs<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw2\">Handles<\/span> TextBox1.<span class=\"me1\">KeyPress<\/span>\n<span class=\"kw6\">Const<\/span> pstr <span class=\"kw2\">As<\/span> <span class=\"kw2\">String<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;0123456789&quot;<\/span>\n<span class=\"kw6\">If<\/span> pstr.<span class=\"me1\">IndexOf<\/span><span class=\"br0\">&#40;<\/span>e.<span class=\"me1\">KeyChar<\/span><span class=\"br0\">&#41;<\/span> <span class=\"sy0\">=<\/span> <span class=\"sy0\">-<\/span>1 <span class=\"kw2\">Then<\/span>\ne.<span class=\"me1\">Handled<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">True<\/span>\n<span class=\"kw6\">End<\/span> <span class=\"kw6\">If<\/span>\n<span class=\"kw6\">End<\/span> <span class=\"kw6\">Sub<\/span><\/pre><\/div><\/div>\n<p>If you want to add &#8220;.&#8221; for exmaple to the combination you can change first line to <div id=\"wpshdo_2\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_2\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_2\"><\/a><a id=\"wpshat_2\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_2\"  onClick=\"javascript:wpsh_toggleBlock(2)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_2\" onClick=\"javascript:wpsh_code(2)\" title=\"Show code only\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png\" \/><\/a>&nbsp;<a href=\"#codesyntax_2\" onClick=\"javascript:wpsh_print(2)\" title=\"Print code\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png\" \/><\/a>&nbsp;<a href=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_2\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"vbnet\" style=\"font-family:monospace;\"><span class=\"kw6\">Const<\/span> pstr <span class=\"kw2\">As<\/span> <span class=\"kw2\">String<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;0123456789&quot;<\/span><\/pre><\/div><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to add &#8220;.&#8221; for exmaple to the combination you can change first line to<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[110],"tags":[84],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/110"}],"collection":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=110"}],"version-history":[{"count":1,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":333,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/110\/revisions\/333"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}