Internet Explorer User's Guide > Using Text Control with HTML and VBScript
Having created a Text Control object on our HTML page, we now need a way to access its methods and properties. Internet Explorer supports VBScript, which is a subset of the Visual Basic programming language. All you need to create a VBScript program is a text editor, and the VBScript Language Reference which is available for download on Microsoft's web site.
As a simple example on how VBScript works, we add a button to our sample program from Step 1, and let it write some text in the Text Control window when you click on it.
A button is created in the BODY section of our HTML page like this:
<FORM> <INPUT NAME="Button1" TYPE="BUTTON" VALUE="Click me!"> </FORM>
In the HEADER part, we add some VBScript code to process the button's OnClick event:
<SCRIPT LANGUAGE="VBScript"> <!-- Sub Button1_OnClick objTX.Text = "Thanks for clicking me!" End Sub --> </SCRIPT>
When the button is clicked on, the script code is executed and assigns some text to Text Control's Text property. All of Text Control's properties and methods can be used like this.
The code shown here is contained in Step2.htm in the \IE\HTML sample source directory.
Now you probably want to add a ButtonBar or a StatusBar. This is a little tricky in IE. There is no event like the Form_Load event in VB. You can't use the <BODY onLoad="..."> event, this is called before the two objects have been created.
But Text Control offers a solution. You can use the BODY onLoad event to set the ButtonBarHandle to 1. This tells TX that you want to set these handle when all controls have been created. So, Text Control fires an event called ConnectTools, when it's ready to receive the handles. The code to do that looks like the following:
<HTML> <HEAD> <TITLE>A Simple First Page</TITLE> <SCRIPT LANGUAGE="VBScript"> <!-- Sub Load() objTX.ButtonBarHandle = 1 End Sub Sub objTX_ConnectTools() objTX.ButtonBarHandle = objBB.hWnd End Sub --> </SCRIPT> </HEAD> <BODY onLoad="Load()">
Where objBB is the ButtonBar object. The class ids for the additional ActiveX controls are:
Button Bar: clsid:621ddb09-a516-11e8-a658-0013d350667c Status Bar: clsid:621ddb11-a516-11e8-a658-0013d350667c Ruler Bar: clsid:621ddb0d-a516-11e8-a658-0013d350667c
Another way to solve this special problem is to build a custom ActiveX control that wraps the TextControl and/or a Button Bar/Status Bar/Ruler Bar.
The code shown here is contained in Step2.htm in the IE\HTML sample source directory.