Microsoft KB Archive/171673: Difference between revisions
(importing KB archive) |
m (Text replacement - "&" to "&") |
||
(One intermediate revision by the same user not shown) | |||
Line 86: | Line 86: | ||
' The Following line displays a Message Box with the date | ' The Following line displays a Message Box with the date | ||
' when the command button is clicked. | ' when the command button is clicked. | ||
msgbox | msgbox "Today's date is " &DATE,64,"My MsgBox" | ||
End sub | End sub | ||
</pre></li> | </pre></li> | ||
Line 118: | Line 118: | ||
' The following example fills a Label control with text | ' The following example fills a Label control with text | ||
' when the command button is clicked. | ' when the command button is clicked. | ||
Label1.Caption= | Label1.Caption="Today's date is " & DATE | ||
End sub | End sub | ||
</pre></li> | </pre></li> | ||
Line 158: | Line 158: | ||
' The following example fills in a text box | ' The following example fills in a text box | ||
' when the command button is clicked | ' when the command button is clicked | ||
TextBox2.Text= | TextBox2.Text="You have entered: "& UCASE(TextBox1.Text) | ||
End sub | End sub | ||
</pre></li> | </pre></li> | ||
Line 198: | Line 198: | ||
' This example evaluates the value of the checkbox and fills | ' This example evaluates the value of the checkbox and fills | ||
' in text in the label when the command button is clicked | ' in text in the label when the command button is clicked | ||
if CheckBox1.Value=TRUE then Label2.Caption= | if CheckBox1.Value=TRUE then Label2.Caption="The checkbox _ | ||
is checked | is checked" | ||
if CheckBox1.Value=FALSE then Label2.Caption= | if CheckBox1.Value=FALSE then Label2.Caption="The checkbox _ | ||
is not checked | is not checked" | ||
end sub | end sub | ||
</pre></li> | </pre></li> | ||
Line 250: | Line 250: | ||
' in text in the label when the command button is clicked | ' in text in the label when the command button is clicked | ||
If OptionButton1.Value=True Then | If OptionButton1.Value=True Then | ||
Label3.Caption = | Label3.Caption = "This option is selected" | ||
Else | Else | ||
Label3.Caption = | Label3.Caption = "The other option is selected" | ||
End If | End If | ||
End sub | End sub | ||
Line 281: | Line 281: | ||
If ToggleButton1.Value = True Then | If ToggleButton1.Value = True Then | ||
ToggleButton1.Caption = | ToggleButton1.Caption = "DEPRESSED" | ||
Else | Else | ||
ToggleButton1.Caption = | ToggleButton1.Caption = "" | ||
End If | End If | ||
End Sub | End Sub | ||
Line 359: | Line 359: | ||
<li>In the ActiveX Control Properties dialog box, do the following: | <li>In the ActiveX Control Properties dialog box, do the following: | ||
<ol style="list-style-type: lower-alpha;"> | <ol style="list-style-type: lower-alpha;"> | ||
<li>In the Pick A Control list, select | <li>In the Pick A Control list, select "Microsoft Forms 2.0 Label."</li> | ||
<li>In the Name box, type <span class="kbd userinput"> Label5</span>.</li> | <li>In the Name box, type <span class="kbd userinput"> Label5</span>.</li> | ||
<li>Click OK.</li></ol> | <li>Click OK.</li></ol> | ||
Line 415: | Line 415: | ||
' selected and fills in the resulting text in the label when | ' selected and fills in the resulting text in the label when | ||
' the command button is clicked | ' the command button is clicked | ||
Label6.Caption= | Label6.Caption= "You have selected " & _ | ||
Listbox1.List(ListBox1.ListIndex) | Listbox1.List(ListBox1.ListIndex) | ||
End sub | End sub | ||
Line 435: | Line 435: | ||
' dim array to populate ListBox | ' dim array to populate ListBox | ||
Dim ListBoxArray(2) | Dim ListBoxArray(2) | ||
ListBoxArray(0)= | ListBoxArray(0)="RED" | ||
ListBoxArray(1)= | ListBoxArray(1)="WHITE" | ||
ListBoxArray(2)= | ListBoxArray(2)="BLUE" | ||
ListBox1.List=ListBoxArray | ListBox1.List=ListBoxArray | ||
End sub | End sub | ||
Line 469: | Line 469: | ||
' selected and fills in the resulting text in the label when | ' selected and fills in the resulting text in the label when | ||
' the command button is clicked. | ' the command button is clicked. | ||
Label7.Caption= | Label7.Caption= "You have selected " & _ | ||
ComboBox1.List(ComboBox1.ListIndex) | ComboBox1.List(ComboBox1.ListIndex) | ||
end sub | end sub | ||
Line 482: | Line 482: | ||
<li><p>In the '''Script''' box, type the following code.<br /> | <li><p>In the '''Script''' box, type the following code.<br /> | ||
<br /> | <br /> | ||
'''NOTE''': Place this code at the bottom of the Script box, after the existing script, but before the last line that reads | '''NOTE''': Place this code at the bottom of the Script box, after the existing script, but before the last line that reads "end sub."</p> | ||
<pre class="codesample"> ' This example creates and populates the array used in the | <pre class="codesample"> ' This example creates and populates the array used in the | ||
' combo box example. | ' combo box example. | ||
Line 488: | Line 488: | ||
' dimension array to populate ComboBox | ' dimension array to populate ComboBox | ||
Dim ListBoxArray(2) | Dim ListBoxArray(2) | ||
ListBoxArray(0)= | ListBoxArray(0)="RED" | ||
ListBoxArray(1)= | ListBoxArray(1)="WHITE" | ||
ListBoxArray(2)= | ListBoxArray(2)="BLUE" | ||
ListBox1.List=ListBoxArray | ListBox1.List=ListBoxArray | ||
</pre></li> | </pre></li> |
Latest revision as of 12:30, 21 July 2020
Article ID: 171673
Article Last Modified on 11/22/2007
APPLIES TO
- Microsoft FrontPage 97 Standard Edition
This article was previously published under Q171673
For a Microsoft FrontPage 98 version of this article, see 180822.
WARNING:
The Microsoft Forms 2.0 package was not designed to work outside 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 additional information, click the article number below to view the article in the Microsoft Knowledge Base:
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. The following 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 FrontPage.
Message Box Example
- On the Insert menu, point to Advanced, and then 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.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, type the following code:
Sub CommandButton1_Click() ' The Following line displays a Message Box with the date ' when the command button is clicked. msgbox "Today's date is " &DATE,64,"My MsgBox" End sub
- Click OK.
Label Example
- On the Insert menu, point to Advanced, and then 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 CommandButton2.
- Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 Label.
- In the Name box, type Label1.
- In the Width box, type 200.
- Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript , and then click to clear the Run Script on Server check box.
In the Script box, type the following code:
Sub CommandButton2_Click() ' The following example fills a Label control with text ' when the command button is clicked. Label1.Caption="Today's date is " & DATE End sub
- Click OK.
Text Box Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 TextBox.
- In the Name box, type TextBox1.
- In the Width box, enter 140.
- Click OK.
- On the Insert menu, point to Advanced, and then 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 CommandButton3.
- Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 TextBox.
- In the Name box, type TextBox2.
- In the Width box, type 300.
- Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, type the following code:
Sub CommandButton3_Click() ' The following example fills in a text box ' when the command button is clicked TextBox2.Text="You have entered: "& UCASE(TextBox1.Text) End sub
- Click OK.
Check Box Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 CheckBox.
- In the Name box, type CheckBox1.
- Click OK.
- On the Insert menu, point to Advanced, and then 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 CommandButton4.
- In the Width box, type 140.
- Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 Label.
- In the Name box, type Label2.
- In the Width box, type 300.
- Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, type the following code:
sub CommandButton4_Click() ' This example evaluates the value of the checkbox and fills ' in text in the label when the command button is clicked 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
- Click OK.
Option Button Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 OptionButton.
- In the Name box, type OptionButton1.
- Click OK.
- On the Insert menu, point to Advanced, and then 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 CommandButton5.
- Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 Label.
- In the Name box, type Label3.
- In the Width box, enter 300.
- Click OK.
- Press ENTER.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 OptionButton.
- In the Name box, type OptionButton2. Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, enter the following code:
Sub CommandButton5_Click() ' This example evaluates the value of the option button and fills ' in text in the label when the command button is clicked If OptionButton1.Value=True Then Label3.Caption = "This option is selected" Else Label3.Caption = "The other option is selected" End If End sub
- Click OK.
Toggle Button Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 ToggleButton.
- In the Name box, type ToggleButton1.
- In the Width box, type 100. In the Height box, type 30.
- Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, enter the following code:
sub ToggleButton1_Click() ' This example evaluates the value of the toggle button and ' fills in text in the label when the command button is clicked. If ToggleButton1.Value = True Then ToggleButton1.Caption = "DEPRESSED" Else ToggleButton1.Caption = "" End If End Sub
- Click OK.
Spin Button Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 SpinButton.
- In the Name box, type SpinButton1.
- Click Properties. In the Properties window, do the following:
- In the Properties list, click Min. In the Value box, type -100. Click Apply.
- Click the Close button in the upper right corner of the Properties window.
- In the Edit ActiveX Control dialog box, click OK.
- Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 Label.
- In the Name box, type Label4.
- Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, type the following code:
sub SpinButton1_SpinDown() ' This example evaluates if the spin button has been depressed and ' fills in text in the label when the command button is clicked Label4.Caption = SpinButton1.Value end sub sub SpinButton1_SpinUp() ' This example evaluates if the spin button has not been depressed ' and fills in text in the label when the command button is clicked Label4.Caption = SpinButton1.Value end sub
- Click OK.
Scroll Bar Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 ScrollBar.
- In the Name box, type ScrollBar1.
- Click Properties. In the Properties window, do the following:
- In the Properties list, click Min.
- In the Value box, type -32766. Click Apply.
- Click the Close button in the upper right corner of the Properties window.
- In the Edit ActiveX Control dialog box, click OK.
- Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select "Microsoft Forms 2.0 Label."
- In the Name box, type Label5.
- Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, enter the following code:
Sub ScrollBar_Change() ' This example evaluates the position of the marker on the scroll ' bar fills in text in the label when the command button is clicked Label5.Caption = -(ScrollBar1.Value) End sub
- Click OK.
List Box Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 ListBox.
- In the Name box, type ListBox1.
- Click Properties. In the Properties window, do the following:
- In the Properties list, click BorderStyle.
- In the Value list, select 1-Single.
- Click Apply.
- Click the Close button in the upper right corner of the Properties window.
- In the Edit ActiveX Control dialog box, click OK.
- Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 Label.
- In the Name box, type Label6.
- In the Width box, enter 400.
- Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, type the following code:
Sub ListBox1_Click() ' This example 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 runs when your page is loaded into a Web browser.
- Click OK.
- Press CTRL+HOME. Press ENTER. Press the UP ARROW key.
The insertion point should be positioned at the beginning of a blank line at the top of the page. - On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, type the following code:
Sub window_onLoad() ' This example creates and populates the array used in the ' proceeding list box example ' dim array to populate ListBox Dim ListBoxArray(2) ListBoxArray(0)="RED" ListBoxArray(1)="WHITE" ListBoxArray(2)="BLUE" ListBox1.List=ListBoxArray End sub
- Click OK.
Combo Box Example
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 ComboBox.
- In the Name box, type ComboBox1. Click OK.
- On the Insert menu, point to Advanced, and then click ActiveX Control.
- In the ActiveX Control Properties dialog box, do the following:
- In the Pick A Control list, select Microsoft Forms 2.0 Label.
- In the Name box, type Label7.
- In the Width box, type 400. Click OK.
- On the Insert menu, point to Advanced, and then click Script.
- In the Script dialog box, do the following:
- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, enter the following code:
sub ComboBox1_Click() ' This example 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 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 loaded into a Web browser.
- Double-click the Script icon at the top of the page.
NOTE: This icon was created in step 6 of the List Box example.- Under Language, click VBScript, and then click to clear the Run Script on Server check box.
In the Script box, type 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."' This example creates and populates the array used in the ' combo box example. ' ' dimension array to populate ComboBox Dim ListBoxArray(2) ListBoxArray(0)="RED" ListBoxArray(1)="WHITE" ListBoxArray(2)="BLUE" ListBox1.List=ListBoxArray
- Click OK.
REFERENCES
For additional information about Microsoft Visual Basic Scripting Edition, visit the following Microsoft Web site:
Additional query words: 97 98 fpscript
Keywords: kbcode kbhowto KB171673