{"id":150,"date":"2010-02-16T10:30:00","date_gmt":"2010-02-16T09:30:00","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=150"},"modified":"2023-01-13T22:41:50","modified_gmt":"2023-01-13T22:41:50","slug":"split-command-sample-code-vb-net","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=150","title":{"rendered":"Split Command Sample Code (VB NET)"},"content":{"rendered":"<p><span style=\"font-size: large;\">Preparations : 1 Textbox and 1 Button<\/span><\/p>\n<p><a onclick=\"javascript:pageTracker._trackPageview('\/downloads\/wp-content\/uploads\/2010\/02\/Untitled1.jpg');\"  href=\"http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled1.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-367\" src=\"http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled1.jpg\" alt=\"\" width=\"346\" height=\"216\" srcset=\"http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled1.jpg 346w, http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled1-300x187.jpg 300w\" sizes=\"(max-width: 346px) 100vw, 346px\" \/><\/a><\/p>\n<p>Code :<\/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;\"><span class=\"kw2\">Private<\/span> <span class=\"kw6\">Sub<\/span> Button1_Click<span class=\"br0\">&#40;<\/span><span class=\"kw2\">ByVal<\/span> sender <span class=\"kw2\">As<\/span> System.<span class=\"kw4\">Object<\/span>, <span class=\"kw2\">ByVal<\/span> e <span class=\"kw2\">As<\/span> System.<span class=\"me1\">EventArgs<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw2\">Handles<\/span> Button1.<span class=\"me1\">Click<\/span>\n&nbsp;\n    <span class=\"kw6\">Dim<\/span> strInput <span class=\"kw2\">As<\/span> <span class=\"kw7\">Array<\/span> <span class=\"co1\">'make array variable<\/span>\n&nbsp;\n    <span class=\"kw6\">Dim<\/span> strResult1 <span class=\"kw2\">As<\/span> <span class=\"kw2\">String<\/span> <span class=\"co1\">'text variable<\/span>\n&nbsp;\n    <span class=\"kw6\">Dim<\/span> strResult2 <span class=\"kw2\">As<\/span> <span class=\"kw2\">String<\/span> <span class=\"co1\">'another text variable<\/span>\n&nbsp;\n    <span class=\"kw6\">Try<\/span>\n&nbsp;\n    strInput <span class=\"sy0\">=<\/span> <span class=\"kw7\">Split<\/span><span class=\"br0\">&#40;<\/span>TextBox1.<span class=\"me1\">Text<\/span>, <span class=\"st0\">&quot; &quot;<\/span><span class=\"br0\">&#41;<\/span>\n&nbsp;\n    <span class=\"co1\">'split the textbox if there is space.<\/span>\n&nbsp;\n    <span class=\"co1\">'you can also use chr(32) to replace &quot; &quot;<\/span>\n&nbsp;\n    strResult1 <span class=\"sy0\">=<\/span> strInput<span class=\"br0\">&#40;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span> <span class=\"co1\">'split first text<\/span>\n&nbsp;\n    strResult2 <span class=\"sy0\">=<\/span> strInput<span class=\"br0\">&#40;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#41;<\/span> <span class=\"co1\">'split second text<\/span>\n&nbsp;\n    <span class=\"kw7\">MsgBox<\/span><span class=\"br0\">&#40;<\/span>strResult1 <span class=\"sy0\">+<\/span> strResult2<span class=\"br0\">&#41;<\/span>\n&nbsp;\n    <span class=\"co1\">'combine first and second text with no space<\/span>\n&nbsp;\n    <span class=\"kw6\">Catch<\/span> ex <span class=\"kw2\">As<\/span> Exception\n&nbsp;\n    <span class=\"kw6\">End<\/span> <span class=\"kw6\">Try<\/span>\n&nbsp;\n    <span class=\"kw6\">End<\/span> <span class=\"kw6\">Sub<\/span><\/pre><\/div><\/div>\n<p><span style=\"font-size: large;\">Test the code, type space character between 2 words :<\/span><\/p>\n<p><a onclick=\"javascript:pageTracker._trackPageview('\/downloads\/wp-content\/uploads\/2010\/02\/Untitled2.jpg');\"  href=\"http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled2.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-369\" src=\"http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled2.jpg\" alt=\"\" width=\"346\" height=\"297\" srcset=\"http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled2.jpg 346w, http:\/\/www.raytawil.com\/wp-content\/uploads\/2010\/02\/Untitled2-300x258.jpg 300w\" sizes=\"(max-width: 346px) 100vw, 346px\" \/><\/a><\/p>\n<p><span style=\"font-size: large;\">What we have done here?<\/span><\/p>\n<p><span style=\"font-size: large;\">Explanation :<\/span><\/p>\n<ol>\n<li><span style=\"font-size: large;\">We have 2 words with a space character (&#8220;jenni&#8221; and &#8220;fer&#8221;)<\/span><\/li>\n<li><span style=\"font-size: large;\">We split those words using &#8220;Split&#8221; command into array, the process is identified with space character, so we had 2 lines.<\/span><\/li>\n<li><span style=\"font-size: large;\">We combine those words back together in one line, but this time with no space character in it.<\/span><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Preparations : 1 Textbox and 1 Button Code : Test the code, type space character between 2 words : What we have done here? Explanation : We have 2 words with a space character (&#8220;jenni&#8221; and &#8220;fer&#8221;) We split those words using &#8220;Split&#8221; command into array, the process is identified with space character, so we [&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":[73,74,89],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/150"}],"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=150"}],"version-history":[{"count":5,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":370,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions\/370"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}