FP2000: How to Use Microsoft Forms 2.0 ActiveX ControlsID: Q208272
|
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.
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
ActiveX Controls are a suite of products and technologies that support Web development, and enable software components to interact with one another. ActiveX Controls are based on the Component Object Model (COM).For more information about ActiveX Controls, please see the following Microsoft World Wide Web site:
http://www.microsoft.com/activex/galleryThe Microsoft Forms 2.0 ActiveX Controls described in this article are included with Microsoft FrontPage.
Sub CommandButton1_Click()
' Displays a message box with text when the command
' button is clicked.
Msgbox "Hello World"
End sub
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms
2.0 Label."
c. Click OK.
d. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "Label1" (without the quotation marks).
Click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CommandButton."
c. Click OK.
d. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "CommandButton2" (without the quotation
marks). Click OK.
Sub CommandButton2_Click()
' The following example fills a Label control with text
' when you click the command button.
Label1.Caption="Hello World"
End sub
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms 2.0
TextBox." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
d. In the Name box, type "TextBox2" (without the quotation
marks). Click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CommandButton."
c. Click OK.
d. Right-click the ActiveX Control and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "CommandButton3" (without the quotation
marks). Click OK.
Sub CommandButton3_Click()
' Text box will be filled in when you click the command
' button.
TextBox2.Text="Hello World"
End sub
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CheckBox." Click OK.
c. Right-click the ActiveX Control and select ActiveX Control
Properties from the Shortcut menu.
d. In the Name box, type "CheckBox1" (without the quotation marks).
e. Click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms 2.0
CommandButton."
c. Click OK.
d. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "CommandButton4" (without the quotation
marks). Click OK
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
Label." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label2" (without the quotation marks).
e. In the Width box, enter 300.
f. Click OK.
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
a. In the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
OptionButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "OptionButton1" (without the quotation marks).
e. Click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CommandButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "CommandButton5" (without the quotation
marks).
e. Click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms 2.0 Label."
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label3" (without the quotation marks).
e. In the Width box, enter 300.
f. Click OK.
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
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
ToggleButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "ToggleButton1" (without the quotation
marks).
e. In the Width box, enter 100.
f. In the Height box, enter 30.
g. Click OK.
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
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
SpinButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "SpinButton1" (without the quotation
marks).
e. Click the Parameter tab and do the following:
1) In the Attribute name list, select Min and then click Modify.
2) In the Data box, type "-100" (without the quotation marks).
3) Click OK.
f. In the ActiveX Control Properties click Apply, and then click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 Label."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label4" (without the quotation marks).
e. Click OK.
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
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
ScrollBar." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "ScrollBar1" (without the quotation
marks).
e. Click the Parameters tab. In the Attribute window, follow these
steps:
1) Select Min and then click Modify
2) In the Value box, type "-32766" (without the quotation marks).
3) Click OK.
f. Click Apply and then click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 Label."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label5" (without the quotation marks).
f. Click OK.
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
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 ComboBox."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "ComboBox1" (without the quotation
marks).
e. Click OK.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 Label."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label7" (without the quotation marks).
e. In the Width box, enter 400.
f. Click OK.
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 executes when your page is opened in a
Web browser.
a. On the Tools menu, point to Macro, and select Microsoft Script Editor.
b. On the HTML menu, point to Script Block, and select Server.
c. 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."
' 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
Additional query words: FP2K activex ie fpscript front page
Keywords : kbole kbdta fpedit fpactive fpscript kbInternet
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: July 1, 1999