{"id":2543,"date":"2017-12-09T05:04:08","date_gmt":"2017-12-09T05:04:08","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=2543"},"modified":"2020-01-09T08:08:14","modified_gmt":"2020-01-09T08:08:14","slug":"function-in-vb-script","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/function-in-vb-script\/","title":{"rendered":"Function in vb script"},"content":{"rendered":"<p><strong>rajani created the topic: function in vb script<\/strong><\/p>\n<p>Develop a function that accepts a string of names separated by comma add those names in an array and display the names added in the array.<\/p>\n<p><strong>rajeshkumar replied the topic: function in vb script<\/strong><\/p>\n<p>Welcome to board&#8230;.<\/p>\n<p>try following snippet&#8230;<\/p>\n<p><code>Sub Funstr(\"str1\", \"str2\")<\/code><\/p>\n<p>a=Array(str1,str2)<br \/>\ndocument.write(a(0))<br \/>\ndocument.write(a(1))<br \/>\nEnd Sub<\/p>\n<p>I would recommend you going through this url as well to learn more about it&#8230;&#8230;<\/p>\n<p><a href=\"http:\/\/www.functionx.com\/vbscript\/Lesson06.htm\" target=\"_blank\" rel=\"noopener\">www.functionx.com\/vbscript\/Lesson06.htm<\/a><\/p>\n<p>Regards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n<p><strong>rajani replied the topic: function in vb script<\/strong><\/p>\n<p>it won&#8217;t work<br \/>\ni have write<br \/>\n&#8220;Develop a function that accepts a string of names separated by comma (example given below), add those names in an array and display the names added in the array&#8221;<\/p>\n<p>Example: rajani; Disha; Dhara; Hunny ;moon<br \/>\nwithout using split function<br \/>\ncan i use mid function<\/p>\n<p><strong>rajani replied the topic: function in vb script<\/strong><\/p>\n<p>i am able to display name but with comma<br \/>\nDim fruits()<br \/>\nReDim fruits(100)<br \/>\nnofruits=0<br \/>\n&#8216;we do not know how many fruit names we are going to enter and so, we have declared the array size as 100<br \/>\nFor i=0 to 100<br \/>\nfruits(i)=inputbox(&#8220;Enter the name of a fruit separated by comma&#8221;)<br \/>\nans = MsgBox(&#8220;Do you want to continue&#8221;, vbYesNo, &#8220;Confirm Continuation&#8230;&#8221;)<br \/>\nIf ans=vbNo Then<br \/>\nExit For<br \/>\nEnd If<br \/>\nnofruits=nofruits+1<br \/>\nNext<br \/>\nReDim Preserve fruits(nofruits)<br \/>\n&#8216;Redim keyword resets the number of elements that can be accommodated in the array.<\/p>\n<p>fruitnames=&#8221;&#8221;<\/p>\n<p>For each fruit in fruits<br \/>\n&#8216;Using For Each Next we have displayed all the names of the fruits which was entered and kept in fruits array.<br \/>\n&#8216;For Each Next extracts the fruit names stored in the array and msgbox displays the output.<\/p>\n<p>fruitnames=fruitnames&amp;fruit&amp;vbnewline<br \/>\nNext<\/p>\n<p>msgbox fruitnames<\/p>\n<p><strong>rajani replied the topic: function in vb script<\/strong><\/p>\n<p>any suggestion<\/p>\n<p><strong>rajani replied the topic: function in vb script<\/strong><\/p>\n<p>dim Array, Str1,X<br \/>\nStr1 = &#8220;Neha; Swati; Disha; Sonya; Dhara&#8221;<br \/>\nArray = split(Str1,&#8221;;&#8221;)<br \/>\nfor each x in Array<br \/>\nmessage = message &amp; x &amp; vbCRLF<br \/>\nnext<br \/>\nmsgbox message<\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajani created the topic: function in vb script Develop a function that accepts a string of names separated by comma add those names in an array and display the names added in the array. rajeshkumar replied the topic: function in vb script Welcome to board&#8230;. try following snippet&#8230; Sub Funstr(&#8220;str1&#8221;, &#8220;str2&#8221;) a=Array(str1,str2) document.write(a(0)) document.write(a(1)) End&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[57],"tags":[278],"class_list":["post-2543","post","type-post","status-publish","format-standard","hentry","category-scripting","tag-script"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=2543"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2543\/revisions"}],"predecessor-version":[{"id":5327,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2543\/revisions\/5327"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=2543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=2543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=2543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}