Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/170495

From BetaArchive Wiki
Knowledge Base


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:

  1. In FrontPage Explorer, open or create a Web.
  2. Open a Web page in FrontPage Editor.
  3. 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

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

    Drop1

  6. Repeat steps 4 and 5 for the remaining form fields. Use the following names:

           Object                        Name
           -------------------------------------
    
           Second Drop-Down Menu         Drop2
           One One Line Text Box         Text1
           One Push Button               Button1
                            
  7. Right-click the first drop-down menu form field, and then click Form Field Properties.
  8. In the Drop-down Menu Properties dialog box, click Add.
  9. In the Add Choice dialog box, enter a number in the Choice box, and then click OK.
  10. Repeat steps 8 and 9 for each additional number you want to enter.
  11. Repeat steps 7 through 10 for the second drop-down form field.
  12. Right-click the push button form field and then click Form Field Properties.
  13. Click Normal, and then click OK.
  14. On the Insert menu, click Script.
  15. Click to select the VBScript check box.
  16. 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
                            
  17. Click OK.
  18. Save the file and preview it in your Web browser.

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


Additional query words: 97 fpscript

Keywords: kbhowto kbusage KB170495