Microsoft KB Archive/208272

= How to use Microsoft Forms 2.0 ActiveX Controls in FrontPage 2000 =

Article ID: 208272

Article Last Modified on 8/15/2006

-

APPLIES TO


 * Microsoft FrontPage 2000 Standard Edition

-



This article was previously published under Q208272





For a Microsoft FrontPage 98 version of this article, see 180822.



For a Microsoft FrontPage 97 version of this article, see 171673.



IN THIS TASK

 * SUMMARY
 * Microsoft Forms 2.0 ActiveX Controls
 * Message Box Example
 * Label Example
 * Text Box Example
 * Check Box Example
 * Option Button Example
 * Toggle Button Example
 * Spin Button Example
 * Scroll Bar Example
 * Combo Box Example
 * REFERENCES



SUMMARY
This article describes how to insert Microsoft Forms 2.0 ActiveX controls in Microsoft FrontPage. In addition, the examples use Microsoft Visual Basic Scripting Edition (VBScript) code to set properties and respond to control events.

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.

back to the top

Microsoft Forms 2.0 ActiveX Controls
The Microsoft Forms 2.0 ActiveX Controls described in this article are included with Microsoft FrontPage.

NOTE: Microsoft Forms 2.0 Controls are not placed automatically in the Insert ActiveX Control list. To do this, click Customize in the Insert ActiveX Control dialog box, select the appropriate control, and then click OK.

back to the top

Message Box Example
 On the Insert menu, point to Advanced, and then click ActiveX Control. In the Select A Control list, select Microsoft Forms 2.0 CommandButton. Click OK. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears. In the Name box, type CommandButton1. Click OK.</li> On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> On the HTML menu, point to Script Block, and then click Server.</li>  Type the following code between the Script tags: Sub CommandButton1_Click ' Displays a message box with text when the command ' button is clicked. Msgbox "Hello World" End sub </li></ol>

back to the top

Label Example
<ol> To insert a Microsoft Forms 2.0 Label, follow these steps: <ol style="list-style-type: lower-alpha;"> On the Insert menu, point to Advanced, and then click ActiveX Control.</li> In the Select A Control list, click to select Microsoft Forms 2.0 Label .</li> Click OK.</li> Right-click the ActiveX Control, and click ActiveX Control Properties on the menu that appears.</li> In the Name box, type Label1. Click OK.</li></ol> </li> To insert a Microsoft Forms 2.0 command button, follow these steps: <ol style="list-style-type: lower-alpha;"> On the Insert menu, point to Advanced, and then click ActiveX Control.</li> In the Select A Control list, select Microsoft Forms 2.0 CommandButton .</li> Click OK.</li> Right-click the ActiveX Control, and click ActiveX Control Properties on the menu that appears.</li> In the Name box, type CommandButton2. Click OK.</li></ol> </li> On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and then click Server.</li> <li> Type the following code between the Script tags: Sub CommandButton2_Click ' The following example fills a Label control with text ' when you click the command button. Label1.Caption="Hello World" End sub </li></ol>

back to the top

Text Box Example
<ol> <li>To insert a Text Box, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the Select A Control list, click to select Microsoft Forms 2.0 TextBox. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type TextBox2. Click OK.</li></ol> </li> <li>Insert a Microsoft Forms 2.0 CommandButton by doing the following: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 CommandButton.</li> <li>Click OK.</li> <li>Right-click the ActiveX Control and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type CommandButton3. Click OK.</li></ol> </li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block and then click Server.</li> <li> Type the following between the Script tags: Sub CommandButton3_Click ' Text box will be filled in when you click the command ' button. TextBox2.Text="Hello World" End sub </li></ol>

back to the top

Check Box Example
<ol> <li>Insert a Microsoft Forms 2.0 CheckBox Control: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 CheckBox. Click OK.</li> <li>Right-click the ActiveX Control and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type CheckBox1.</li> <li>Click OK.</li></ol> </li> <li>To insert a Microsoft Forms 2.0 command button, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the Select A Control list, click to select Microsoft Forms 2.0 CommandButton.</li> <li>Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type CommandButton4. Click OK.</li></ol> </li> <li>To insert a Microsoft Forms 2.0 Label, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 Label. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties.</li> <li>In the Name box, type Label2 .</li> <li>In the Width box, type 300 .</li> <li>Click OK.</li></ol> </li> <li>On the Tools menu, point to Macro, and select Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and click Server.</li> <li> Type the following code between the Script tags: sub CommandButton4_Click ' Evaluates the value of the check box and inserts text ' in the label when you click the command button. if CheckBox1.Value=TRUE then Label2.Caption="The checkbox _            is checked" if CheckBox1.Value=FALSE then Label2.Caption="The checkbox _            is not checked" end sub </li></ol>

back to the top

Option Button Example
<ol> <li>To insert a Microsoft Forms 2.0 option button, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>In the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 OptionButton. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties.</li> <li>In the Name box, type OptionButton1 .</li> <li>Click OK.</li></ol> </li> <li>To insert a Microsoft Forms 2.0 command button, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, select Microsoft Forms 2.0 CommandButton. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type CommandButton5.</li> <li>Click OK.</li></ol> </li> <li>To insert a Microsoft Forms 2.0 label, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 Label.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type Label3 .</li> <li>In the Width box, type 300 .</li> <li>Click OK.</li></ol> </li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and then click Server.</li> <li> Type the following code between the Script tags: Sub CommandButton5_Click ' Evaluates the value of the option button and inserts ' text in the label when you click the command button. If OptionButton1.Value=True Then Label3.Caption = "This option is selected" Else Label3.Caption = "The other option is selected" End If         End sub </li></ol>

back to the top

Toggle Button Example
<ol> <li>To insert a Microsoft Forms 2.0 toggle button, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 ToggleButton. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type ToggleButton1 .</li> <li>In the Width box, type 100 .</li> <li>In the Height box, type 30.</li> <li>Click OK.</li></ol> </li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and then click Server.</li> <li> Type the following code between the Script tags: sub ToggleButton1_Click ' Evaluates the value of the toggle button and inserts text ' in the label when you click the command button. If ToggleButton1.Value = True Then ToggleButton1.Caption = "DEPRESSED" Else ToggleButton1.Caption = "" End If         End Sub </li></ol>

back to the top

Spin Button Example
<ol> <li>To insert a Microsoft Forms 2.0 spin button, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 SpinButton. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type SpinButton1 .</li> <li>Click the Parameter tab and do the following: <ol> <li>In the Attribute name list, click Min, and then click Modify.</li> <li>In the Data box, type -100 .</li> <li>Click OK.</li></ol> </li> <li>In the ActiveX Control Properties dialog box, click Apply, and then click OK.</li></ol> </li> <li>To insert a Microsoft Forms 2.0 label, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, click Microsoft Forms 2.0 Label.

Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type Label4 .</li> <li>Click OK.</li></ol> </li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and then click Server.</li> <li> Type the following code between the Script tags: sub SpinButton1_SpinDown ' Evaluates if the spin button has been clicked and ' inserts text in the label when you click the ' command button. Label4.Caption = SpinButton1.Value end sub

sub SpinButton1_SpinUp ' Evaluates if the spin button has not been clicked ' and inserts text in the label when you click the ' command button. Label4.Caption = SpinButton1.Value end sub

</li></ol>

back to the top

Scroll Bar Example
<ol> <li>To insert a Microsoft Forms 2.0 scroll bar, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, select Microsoft Forms 2.0 ScrollBar. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type ScrollBar1 .</li> <li>Click the Parameters tab. In the Attribute window, follow these steps: <ol> <li>Select Min and then click Modify.</li> <li>In the Value box, type -32766 .</li> <li>Click OK.</li></ol> </li> <li>Click Apply and then click OK.</li></ol> </li> <li>To insert a Microsoft Forms 2.0 label, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the Select A Control list, select Microsoft Forms 2.0 Label. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type Label5 .</li> <li>Click OK.</li></ol> </li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and select Server.</li> <li> Type the following code between the Script tags: Sub ScrollBar_Change ' Evaluates the position of the marker on the scroll bar and ' inserts text in the label when the command button is         ' clicked. Label5.Caption = -(ScrollBar1.Value) End sub </li></ol>

back to the top

Combo Box Example
<ol> <li>On the Insert menu, point to Advanced, and then click ActiveX Control. <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, select Microsoft Forms 2.0 ComboBox. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type ComboBox1 .</li> <li>Click OK.</li></ol> </li> <li>To insert a Microsoft Forms 2.0 label, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the Select A Control list, select Microsoft Forms 2.0 Label. Click OK.</li> <li>Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.</li> <li>In the Name box, type Label7 .</li> <li>In the Width box, type 400 .</li> <li>Click OK.</li></ol> </li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and then click Server.</li> <li> Type the following code between the Script tags: sub ComboBox1_Click ' Evaluates which option in a combo box has been ' selected and fills in the resulting text in the label ' when the command button is clicked Label7.Caption= "You have selected " & _ ComboBox1.List(ComboBox1.ListIndex) end sub NOTE: A ComboBox requires you to write script that populates the list with values in an array. The script should be inserted at the top of the page so that it runs when your page is opened in a Web browser. </li> <li> To insert the script to populate the Microsoft Forms 2.0 combo box, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>On the Tools menu, point to Macro, and select Microsoft Script Editor.</li> <li>On the HTML menu, point to Script Block, and then click Server.</li> <li>Type the following code between the Script tags.

NOTE: Place this code at the bottom of the Script box, after the existing script, but before the last line that reads "end sub."</li></ol>

' Creates and populates the array used in the ' preceding list box example. '         ' Dimension array to populate the list box. Dim ListBoxArray(2) ListBoxArray(0)="RED" ListBoxArray(1)="WHITE" ListBoxArray(2)="BLUE" ListBox1.List=ListBoxArray </li></ol>

back to the top

<div class="references_section">