VBScript implements InputBox multiple input boxes and InputBox and CheckBox boxes

Source: Internet
Author: User

VBScript is not implemented InputBox multiple input boxes appear in the same dialog, but if you use IE, you can achieve the same effect.

Found an example of an expert on the Internet, posted below

<textarea cols= "rows=" name= "code" class= "VB" >wscript.echo "This example is a copy of the picture you posted" ss = Multiinputbox ("instance", " The file or folder to search for is named: ^^ m| contains text: ^^ C ") wscript.echo" The filename entered is: "&amp; SS (0) WScript.Echo "contains text is:" &amp; SS (1) ' ************************************************************** ' * &ldquo; VBS multi-input box &rdquo; (P) &amp; (C) 2010 "said to be Mr. Lee" ' * ' * The return value is an array, followed by the individual input values. ' * ' * title: Input box title ' * ' * content: A string containing display information, specific format for ' * ' * hint Info ^ default value ^ Hot Key | Hint Info ^ Default ^ Hotkey | ... ' * ' * &ldquo;^&rdquo; and &ldquo;|&rdquo; Do the separator, only the hint information is required ' * ' hot key: a character, such as &ldquo; M&rdquo, hold down ALT, and then press M to quickly navigate to this input box ' * ' *************************************************************** Function Multiinputbox (title, content) Dim htmlstr, temp, I, l, height, allinputs, input, Contentarr (), result () temp = Split (conte NT, "|") ReDim Contentarr (UBound (temp)) For i = 0 to UBound (temp) Contentarr (i) = Split (Temp (i), "^") Next L = UBound (Contentarr) R Edim result (l) height = l * + htmlstr = "&lt;html&gt;&Lt;head&gt;&lt;title&gt; "&amp; Title &amp; "&lt;/title&gt;" htmlstr = Htmlstr &amp; "&lt;meta http-equiv=content-type content=" "text/html; charset=gb18030 "" &gt; "htmlstr = Htmlstr &amp; "&lt;mce:style type=" "Text/css" "&gt;&lt;! --*{font:12px/1.2em Arial; . Input_box{width:250px;height:23px;padding-top:3px;border-color: #CCC; color: #333; Background-color: #EEE;}--& Gt;&lt;/mce:style&gt;&lt;mce:style type= "" Text/css "" mce_bogus= "1" &gt;&lt;! --*{font:12px/1.2em Arial; . Input_box{width:250px;height:23px;padding-top:3px;border-color: #CCC; color: #333; Background-color: #EEE;}--& Gt;&lt;/mce:style&gt;&lt;style type= "" Text/css "" mce_bogus= "1" mce_bogus= "1" &gt;*{font:12px/1.2em Arial; . Input_box{width:250px;height:23px;padding-top:3px;border-color: #CCC; color: #333; Background-color: #EEE;} &lt;/style&gt; "HTMLSTR = Htmlstr &amp; "&lt;mce:script type=" "Text/javascript" "&gt;&lt;! --function CF (e) {if (E.altkey) Try{eval (String.fromCharCode (E.keycode)). Focus ()}catch (e) {};}//--&gt;&lt;/ mce:script&gt; "HTMLSTR = Htmlstr &amp; "&lt;/head&gt;&lt;body scroll=" "No" "onkeyup=" "CF (event)" "&gt;" For i = 0 to l temp = "&lt;input onfocus=" "Javascript:this.select ();" "Class=" "Input_box" "type=" "Text" "If UBound (CO Ntentarr (i) &gt; 0 Then temp = temp &amp; "" "Value=" "" &amp; Contentarr (i) (1) If UBound (Contentarr (i)) &gt; 1 Then temp = temp &amp; "" "Name=" "" &amp; UCase (Contentarr (i) (2)) temp = Contentarr (i) (0) &amp; "(&lt;u&gt;" &amp; UCase (Contentarr (i) (2)) &amp; "&lt;/u&gt;) &lt;br&gt;" &amp; Temp Else temp = Contentarr (i) (0) &amp; "&lt;br&gt;" &amp; Temp End If Temp = temp &amp; "" "/&gt;&lt;br&gt;&lt;br&gt;" htmlstr = Htmlstr &amp; Temp Next htmlstr = htmlstr &amp; "&lt;br&gt;&lt;input type=" "Hidden" "name=" "Ching""Value=" "Me" "/&gt;" htmlstr = Htmlstr &amp; "&lt;input type=" "button" "value=" "OK" "onclick=" "javascript:ching.value= ' Ching ';" " /&gt; "HTMLSTR = Htmlstr &amp; "&lt;input type=" "button" "Value=" "Cancel" "onclick=" "javascript:ching.value= ' Caofackri ';" " /&gt; "HTMLSTR = Htmlstr &amp; "&lt;/body&gt;&lt;/html&gt;" ' I wanted to use Umu to empty the data at the point close, but that would have to be split into at least two functions, so instead of error ignoring. With WScript.CreateObject ("Internetexplorer.application", "Umu_"). menubar=0:.addressbar=0:.toolbar=0:.statusbar= 0:.resizable=0. Width=300:.height=height:.navigate "About:blank":. visible=1. document.write htmlStr do on Error Resume Next wscript.sleep document.body.all.ching.value = "Ching" Then Set allinputs =. document.getElementsByTagName ("I Nput ") i = 0 for each input in allinputs If i &gt; L Then Exit for result (i) = Input.value i = i + 1 Next. Quit Exit do End If. Document.body.all.ching.value = "Caofackri" Then. Quit Exit do-if Err.Number &lt;&gt; 0 Then Exit Do Loop End and Multiinputbox = result end function</textarea>

For the application of the work, the above code has been modified to a number of InputBox and checkbox box combination display

Glue the code to the bottom

<textarea cols= "rows=" name= "code" class= "vb" > strsetting = Multiinputbox ("Setting:", "Execute1:|execute2 : |input the Execute3:|input times of Execute4: ") WScript.Echo strsetting (0) &amp;strsetting (1) &amp; Strsetting (2) &amp;strsetting (3) if strsetting (0) = "Execute" Then MsgBox ("The" the "is checked") End If ' * * * * Function Multiinputbox (title, content) Dim Htmlstr, Temp , I, L, height, allinputs, input, Contentarr, result () Contentarr = Split (content, "|") L = UBound (Contentarr) ReDim Resul T (l) Contentarr (0) =contentarr (0) + "&nbsp;" + "&nbsp;" + "&nbsp;" height = L * + 155-2 * 15-5 htmlstr = "&lt;html&gt;&lt;head&gt;&lt;title&gt;" &amp; Title &amp; "&lt;/title&gt;" htmlstr = Htmlstr &amp; "&lt;meta http-equiv=content-type content=" "text/html; charset=gb18030 "" &gt; "htmlstr = Htmlstr &amp; "&lt;mce:style type=" "Text/css" "amp;gt;&lt;! --*{font:12px/1.2em Arial; . Input_box{width:250px;height:23px;padding-top:3px;border-color: #CCC; color: #333; Background-color: #EEE;}--& Gt;&lt;/mce:style&gt;&lt;style type= "" Text/css "" mce_bogus= "1" &gt;*{font:12px/1.2em Arial. Input _box{width:250px;height:23px;padding-top:3px;border-color: #CCC; color: #333; Background-color: #EEE;} &lt;/style&gt; "HTMLSTR = Htmlstr &amp; "&lt;mce:style type=" "Text/css" "&gt;&lt;! --*{font:12px/1.2em Arial; . Check_box{width:30px;height:20px;padding-top:1px;border-color: #CCC; color: #333; Background-color: #EEE;}--& Gt;&lt;/mce:style&gt;&lt;style type= "" Text/css "" mce_bogus= "1" &gt;*{font:12px/1.2em Arial. Check _box{width:30px;height:20px;padding-top:1px;border-color: #CCC; color: #333; Background-color: #EEE;} &lt;/style&gt; "HTMLSTR = Htmlstr &amp; "&lt;mce:script type=" "Text/javascript" "&gt;&lt;! --Function CF (e) {if (E.altkey) Try{eval (String.fromCharCode) (E.keycoDE)). Focus ()}catch (e) {};} --&gt;&lt;/mce:script&gt; "HTMLSTR = Htmlstr &amp; "&lt;mce:script type=" "Text/javascript" "&gt;&lt;! --function Check (obj) {for (I=0;i&lt;document.all (obj). length;i++) {document.all (obj) [i].value= '; if ( document.all (obj) [i].checked) document.all (obj) [i].value= ' Execute '}}//--&gt;&lt;/mce:script&gt; Htmlstr = Htmlstr &amp; "&lt;/head&gt;&lt;body scroll=" "No" "onkeyup=" "CF (event)" "&gt;" For i = 0 to l If (i = 0 Or i =1) Then temp = "&lt;input onfocus=" "Javascript:this.select ();" class= "" Check_box "" Name = "" "Checkboxes" "Type=" "checkbox" "onclick=" Check (' checkboxes ') ""; temp = Contentarr (i) &amp; Temp ' &amp; "&lt;br&gt;" temp = temp &amp; "" "/&gt;&lt;br&gt;&lt;br&gt;" ' Htmlstr = Htmlstr &amp; Temp Else temp = "&lt;input onfocus=" "Javascript:this.select ();" "Class=" "Input_box" "type=" "Text" "" TEMP = Contentarr (i) &amp; "&lt;br&gt;" &amp; Temp TEMP = Temp &amp; "" "/&gt;&lt;br&gt;&lt;br&gt;" htmlstr = Htmlstr &amp; Temp end If Next htmlstr = Htmlstr &amp; "&lt;br&gt;&lt;input type=" "Hidden" "name=" "Ching" "Value=" "Me" "/&gt;" htmlstr = Htmlstr &amp; "&lt;input type=" "button" "value=" "OK" "onclick=" "javascript:ching.value= ' OK"; " /&gt; "HTMLSTR = Htmlstr &amp; "&lt;input type=" "button" "Value=" "Cancel" "onclick=" "Javascript:ching.value= ' Cancel"; " /&gt; "HTMLSTR = Htmlstr &amp; "&lt;/body&gt;&lt;/html&gt;" With WScript.CreateObject ("Internetexplorer.application", "Umu_"). menubar=0:.addressbar=0:.toolbar=0:.statusbar= 0:.resizable=0. Width=300:.height=height:.navigate "About:blank":. visible=1. document.write htmlStr do on Error Resume Next Wscript.Sleep document.body.all.ching.value = "OK" Then Set allinputs =. document.getElementsByTagName ("Inpu T ") i = 0 for each input in allinputs If i &gt; L Then Exit for ResUlt (i) = Input.value i = i + 1 Next. Quit Exit Do-if-Document.body.all.ching.value = "Cancel" Then. Quit Exit do-if Err.Number &lt;&gt; 0 Then Exit do Loop end and Multiinputbox = result end function</textarea> 

In fact, can also be similar to a single box, multiple selection of boxes, text boxes and other combinations, on the basis of the above to improve on it ~ ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.