Microsoft KB Archive/170495

= FP97: Sample VBScript to Calculate Contents of Drop-Down Lists =

Article ID: 170495

Article Last Modified on 8/27/2007

-

APPLIES TO


 * Microsoft FrontPage 97 Standard Edition

-



This article was previously published under Q170495





SUMMARY
This article provides a sample Visual Basic Script that calculates the contents of a drop-down list and displays the results in a text box.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To create a sample Visual Basic scripting program to add the contents of multiple drop-down menus, follow these steps:  In FrontPage Explorer, open or create a Web. Open a Web page in FrontPage Editor. Insert the following form fields, by pointing to Form Field on the Insert menu, and then clicking the appropriate command:

Two drop-down menus

One one-line text box

One push button

 Right-click the first drop-down menu form field and then click Form Field Properties. In the Name box, type the following name, and then click OK:

Drop1

  Repeat steps 4 and 5 for the remaining form fields. Use the following names: <pre class="fixed_text">      Object                        Name -

Second Drop-Down Menu        Drop2 One One Line Text Box        Text1 One Push Button              Button1 </li> Right-click the first drop-down menu form field, and then click Form Field Properties.</li> In the Drop-down Menu Properties dialog box, click Add.</li> In the Add Choice dialog box, enter a number in the Choice box, and then click OK.</li> Repeat steps 8 and 9 for each additional number you want to enter.</li> Repeat steps 7 through 10 for the second drop-down form field.</li> Right-click the push button form field and then click Form Field Properties.</li> Click Normal, and then click OK.</li> On the Insert menu, click Script.</li> Click to select the VBScript check box.</li>  In the Script box, type the following code: sub button1_onclick

' Create the form object. dim theform set theform = document.form1

' Return the value from the first drop-down menu. Drop-down text ' boxes return values as text. The Cint function converts text

' into an integer. firstvalue = Cint(theform.drop1.options _        (theform.drop1.selectedindex).text)

' Return the value from the second drop-down menu. secondvalue = Cint(theform.drop2.options _        (theform.drop2.selectedindex).text)

' Display the results in a text box. theform.Text1.value = firstvalue + secondvalue

end sub </li> Click OK.</li> Save the file and preview it in your Web browser.</li></ol>

For additional information about Microsoft Visual Basic Scripting, please see the following Microsoft Web site:

http://www.microsoft.com/technet/scriptcenter/default.mspx

Additional query words: 97 fpscript

Keywords: kbhowto kbusage KB170495

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.