{"id":97,"date":"2009-12-23T13:28:07","date_gmt":"2009-12-23T12:28:07","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=97"},"modified":"2010-07-26T13:53:56","modified_gmt":"2010-07-26T13:53:56","slug":"clearing-all-textboxes-on-a-form","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=97","title":{"rendered":"Clearing all textboxes on a Form"},"content":{"rendered":"<p>Do you have a form that has a lot of textboxes?<\/p>\n<p>do you want to clear all those textboxes for example when there is a new?<\/p>\n<p>this is the old scenario:<\/p>\n<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;\">TextBox1.<span class=\"me1\">Text<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span>\nTextBox2.<span class=\"me1\">Text<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span>\nTextBox3.<span class=\"me1\">Text<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span>\nTextBox4.<span class=\"me1\">Text<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span>\nTextBox5.<span class=\"me1\">Text<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span><\/pre><\/div><\/div>\n<p>etc&#8230;&#8230;&#8230;&#8230;<br \/>\nthis is my idea:<\/p>\n<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\">Sub<\/span> ClearForm<span class=\"br0\">&#40;<\/span><span class=\"kw2\">ByVal<\/span> frm_name <span class=\"kw2\">As<\/span> Form<span class=\"br0\">&#41;<\/span>\n<span class=\"kw6\">Dim<\/span> Contrl <span class=\"kw2\">As<\/span> Control\n<span class=\"kw2\">For<\/span> <span class=\"kw6\">Each<\/span> Contrl In frm_name.<span class=\"me1\">Controls<\/span>\n<span class=\"kw6\">If<\/span> <span class=\"br0\">&#40;<\/span>TypeOf Contrl <span class=\"kw2\">Is<\/span> TextBox<span class=\"br0\">&#41;<\/span> <span class=\"kw2\">Then<\/span> Contrl.<span class=\"me1\">Text<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span>\n<span class=\"kw2\">Next<\/span> Contrl\n<span class=\"kw6\">End<\/span> <span class=\"kw6\">Sub<\/span><\/pre><\/div><\/div>\n<p>this is my friend <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/samir-ibrahim.spaces.live.com\/blog\/');\" title=\"Samir Ibrahim\"  href=\"http:\/\/samir-ibrahim.spaces.live.com\/blog\/\" target=\"_blank\">samir ibrahim<\/a>&#8216;s idea, compatible with &#8220;.net framework 3.5 +&#8221;<\/p>\n<div id=\"wpshdo_3\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_3\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_3\"><\/a><a id=\"wpshat_3\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_3\"  onClick=\"javascript:wpsh_toggleBlock(3)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_3\" onClick=\"javascript:wpsh_code(3)\" 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_3\" onClick=\"javascript:wpsh_print(3)\" 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_3\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"vbnet\" style=\"font-family:monospace;\"><span class=\"kw2\">For<\/span> <span class=\"kw6\">Each<\/span> _Ctrl <span class=\"kw2\">As<\/span> Control In <span class=\"kw2\">Me<\/span>.<span class=\"me1\">Controls<\/span>.<span class=\"me1\">OfType<\/span><span class=\"br0\">&#40;<\/span>Of TextBox<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span>\n_Ctrl.<span class=\"me1\">Text<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span>\n<span class=\"kw2\">Next<\/span><\/pre><\/div><\/div>\n<p>The second idea is more optimized with same result.<\/p>\n<p>Of course my idea is cooler because i made it <img decoding=\"async\" onclick=\"grin(':mrgreen:');\" src=\"..\/wp-includes\/images\/smilies\/icon_mrgreen.gif\" alt=\":mrgreen:\" \/><\/p>\n<p>you just need to pass the form name to the function &amp; it will clear the form for you, this will save your fingers extensive redundant typing <img decoding=\"async\" onclick=\"grin(':mrgreen:');\" src=\"..\/wp-includes\/images\/smilies\/icon_mrgreen.gif\" alt=\":mrgreen:\" \/><img decoding=\"async\" onclick=\"grin(':mrgreen:');\" src=\"..\/wp-includes\/images\/smilies\/icon_mrgreen.gif\" alt=\":mrgreen:\" \/><img decoding=\"async\" onclick=\"grin(':mrgreen:');\" src=\"..\/wp-includes\/images\/smilies\/icon_mrgreen.gif\" alt=\":mrgreen:\" \/><img decoding=\"async\" onclick=\"grin(':mrgreen:');\" src=\"..\/wp-includes\/images\/smilies\/icon_mrgreen.gif\" alt=\":mrgreen:\" \/><img decoding=\"async\" onclick=\"grin(':mrgreen:');\" src=\"..\/wp-includes\/images\/smilies\/icon_mrgreen.gif\" alt=\":mrgreen:\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you have a form that has a lot of textboxes? do you want to clear all those textboxes for example when there is a new? this is the old scenario: etc&#8230;&#8230;&#8230;&#8230; this is my idea: this is my friend samir ibrahim&#8216;s idea, compatible with &#8220;.net framework 3.5 +&#8221; The second idea is more optimized [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[110],"tags":[24,25,83],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/97"}],"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=97"}],"version-history":[{"count":2,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":279,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions\/279"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}