Step 2 - Programming with 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:

  <INPUT NAME="Button1" TYPE="BUTTON" VALUE="Click me!">

In the HEADER part, we add some VBScript code to process the button's OnClick event:

Sub Button1_OnClick
  objTX.Text = "Thanks for clicking me!"
End Sub

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:

      <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
<BODY onLoad="Load()">

Where objBB is the ButtonBar object. The class ids for the additional ActiveX controls are:

Button Bar: clsid:b89a2c09-99dd-11e6-a5ed-0013d350667c
Status Bar: clsid:b89a2c11-99dd-11e6-a5ed-0013d350667c
Ruler Bar:  clsid:b89a2c0d-99dd-11e6-a5ed-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.