The information in this article applies to:
- Microsoft FrontPage 97 for Windows with Bonus Pack
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, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose. This article assumes that you are familiar with the programming
language being demonstrated and the tools used to create and 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
needs. If you have limited programming experience, you may want to contact
the Microsoft fee-based consulting line at (800) 936-5200. For more
information about the support options available from Microsoft, please see
the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.asp
To create a sample Visual Basic scripting program to add the contents of
multiple drop-down menus, use the following 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:
Object Name
====== ====
Second Drop-Down Menu Drop2
One One Line Text Box Text1
One Push Button Button1
- Right-click the first drop-down menu form field and then click Form
Field Properties.
- In the Drop-down Menu Properties dialog box, click Add.
- In the Add Choice dialog box, enter a number in the Choice box, and
then click OK.
- Repeat steps 8 and 9 for each additional number you want to enter.
- Repeat steps 7 through 10 for the second drop-down form field.
- Right-click the push button form field and then click Form Field
Properties.
- Click Normal, and then click OK.
- On the Insert menu, click Script.
- Click to select the VBScript check box.
- 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
- Click OK.
- 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:
http://www.microsoft.com/vbscript/
|