Microsoft KB Archive/180822

= FP98: How to Use Microsoft Forms 2.0 ActiveX Controls =

Article ID: 180822

Article Last Modified on 8/27/2007

-

APPLIES TO


 * Microsoft FrontPage 98 Standard Edition

-



This article was previously published under Q180822



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

WARNING:
The Microsoft Forms 2.0 package was not designed to work outside of the Visual Basic for Applications environment. While individual developers might be successful in deploying it to containers such as Microsoft Internet Explorer, using Forms in this manner is neither recommended nor supported. For more information, see the following Microsoft Knowledge Base article:

236458 Using Microsoft Forms 2.0 in Internet Explorer



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



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. The Microsoft Forms 2.0 ActiveX Controls described in this article are included with Microsoft FrontPage.

Message Box Example
 On the Insert menu, point to Advanced, and click ActiveX Control. In the ActiveX Control Properties dialog box, do the following:  In the Pick A Control list, select "Microsoft Forms 2.0 CommandButton." In the Name box, type CommandButton1  Click OK. </li> On the Insert menu, point to Advanced, and click Script.</li> In the Script dialog box, do the following:  Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li>  In the Script box, enter the following code: Sub CommandButton1_Click ' Displays a message box with the date when the command ' button is clicked. msgbox "Today's date is " &DATE,64,"My MsgBox" End sub </li></ol> </li> Click OK.</li></ol>

Label Example
 On the Insert menu, point to Advanced, and click ActiveX Control.</li> In the ActiveX Control Properties dialog box, do the following:  In the Pick A Control list, select "Microsoft Forms 2.0

CommandButton."</li> In the Name box, type CommandButton2 .</li> Click OK.</li></ol> </li> On the Insert menu, point to Advanced, and click ActiveX Control.</li> In the ActiveX Control Properties dialog box, do the following:  <li>In the Pick A Control list, select "Microsoft Forms 2.0 Label."</li> <li>In the Name box, type Label1 .</li> <li>In the Width box, enter 200.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li>Click to the right of the Label to cancel the selection.</li> <li> In the Script box, enter the following code:          Sub CommandButton2_Click             ' The following example fills a Label control with text ' when you click the command button. Label1.Caption="Today's date is " & DATE End sub </li> <li>Click OK.</li></ol> </li></ol>

Text Box Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 TextBox."</li> <li>In the Name box, type TextBox1 .</li> <li>In the Width box, enter 140.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 CommandButton."</li> <li>In the Name box, type CommandButton3 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 TextBox."</li> <li>In the Name box, type TextBox2 .</li> <li>In the Width box, enter 300.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: Sub CommandButton3_Click ' Text box will be filled in when you click the command ' button. TextBox2.Text="You have entered: "& UCASE(TextBox1.Text) End sub </li> <li>Click OK.</li></ol> </li></ol>

Check Box Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 CheckBox."</li> <li>In the Name box, type CheckBox1 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 CommandButton."</li> <li>In the Name box, type CommandButton4 .</li> <li>In the Width box, enter 140.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 Label."</li> <li>In the Name box, type Label2 .</li> <li>In the Width box, enter 300.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: 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> <li>Click OK.</li></ol> </li></ol>

Option Button Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 OptionButton."</li> <li>In the Name box, type OptionButton1 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 CommandButton."</li> <li>In the Name box, type CommandButton5 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 Label."</li> <li>In the Name box, type Label3 .</li> <li>In the Width box, enter 300.</li> <li>Click OK.</li></ol> </li> <li>Press ENTER. The pointer will move to a new line.</li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 OptionButton."</li> <li>In the Name box, type OptionButton2 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: 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> <li>Click OK.</li></ol> </li></ol>

Toggle Button Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 ToggleButton."</li> <li>In the Name box, type ToggleButton1 .</li> <li>In the Width box, enter 100.</li> <li>In the Height box, enter 30.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: 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> <li>Click OK.</li></ol> </li></ol>

Spin Button Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 SpinButton."</li> <li>In the Name box, type SpinButton1 .</li> <li>Click Properties. In the Properties window, do the following: <ol> <li>In the Properties list, click Min.</li> <li>In the Value box, type -100 .</li> <li>Click Apply.</li> <li>Click the Close button in the top right corner of the Properties window.</li> <li>In the Edit ActiveX Control dialog box, click OK.</li></ol> </li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 Label."</li> <li>In the Name box, type Label4 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: 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> <li>Click OK.</li></ol> </li></ol>

Scroll Bar Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 ScrollBar."</li> <li>In the Name box, type ScrollBar1 .</li> <li>Click Properties. In the Properties window, do the following: <ol> <li>In the Properties list, click Min.</li> <li>In the Value box, type -32766 .</li> <li>Click Apply.</li> <li>Click the Close button in the top right corner of the Properties window.</li> <li>In the Edit ActiveX Control dialog box, click OK.</li></ol> </li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 Label."</li> <li>In the Name box, type Label5 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: Sub ScrollBar1_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> <li>Click OK.</li></ol> </li></ol>

List Box Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 ListBox."</li> <li>In the Name box, type ListBox1 .</li> <li>Click Properties. In the Properties window, do the following: <ol> <li>In the Properties list, click BorderStyle.</li> <li>In the Value list, select 1-Single.</li> <li>Click Apply.</li> <li>Click the Close button in the top right corner of the Properties window.</li> <li>In the Edit ActiveX Control dialog box, click OK.</li></ol> </li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and then click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 Label."</li> <li>In the Name box, type Label6 .</li> <li>In the Width box, enter 400.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: Sub ListBox1_Click ' Evaluates which option in a list box has been ' selected and fills in the resulting text in the label ' when the command button is clicked. Label6.Caption= "You have selected " & _ Listbox1.List(ListBox1.ListIndex) End sub

NOTE: A ListBox 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 executes when your page is opened in a Web browser. </li></ol> </li> <li>Press CTRL+HOME. Press ENTER. Press the UP ARROW key. The pointer should be positioned at the beginning of a blank line at the top of the page.</li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: Sub window_onLoad ' 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 End sub </li> <li>Click OK.</li></ol> </li></ol>

Combo Box Example
<ol> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, select "Microsoft Forms 2.0 ComboBox."</li> <li>In the Name box, type ComboBox1 .</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click ActiveX Control.</li> <li>In the ActiveX Control Properties dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>In the Pick A Control list, "select Microsoft Forms 2.0 Label."</li> <li>In the Name box, type Label7 .</li> <li>In the Width box, enter 400.</li> <li>Click OK.</li></ol> </li> <li>On the Insert menu, point to Advanced, and click Script.</li> <li>In the Script dialog box, do the following: <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code: 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 </li> <li>Click OK.

NOTE: A ListBox 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 executes when your page is opened in a Web browser.</li></ol> </li> <li>Double-click the Script icon at the top of the page.

NOTE: This icon was created in step 6 of the List Box example. <ol style="list-style-type: lower-alpha;"> <li>Under Language, click VBScript and click to clear the "Run Script on Server" check box.</li> <li> In the Script box, enter the following code.

NOTE: Place this code at the bottom of the Script box, after the existing script, but before the last line that reads "end sub." ' Creates and populates the array used in the ' preceding list box example. '         ' Dimension array to populate the list box. Dim ComboBoxArray(2) ComboBoxArray(0)="RED" ComboBoxArray(1)="WHITE" ComboBoxArray(2)="BLUE" ComboBox1.List=ComboBoxArray </li> <li>Click OK.</li></ol> </li></ol>

<div class="references_section">