Full HTML for

Basic foilset Introduction to ActiveX, with VBScript

Given by Nancy J. McCracken at CPS616 -- Information Track of CPS on Spring Semester 97. Foils prepared 4 May 97
Outside Index Summary of Material


This talk is designed to describe the capabilities of ActiveX with VBScript for people who know Java and JavaScript. It will give some examples and mention key features without getting into serious programming details.
Outline:
  • General discussion of features and comparison with Java/JavaScript
  • Simple example of preparing a web page using the ActiveX Control Pad to add some built-in controls and the Script Wizard to attach a built-in VBScript.
  • More details on ActiveX
  • More details on VBScript

Table of Contents for full HTML of Introduction to ActiveX, with VBScript

Denote Foils where Image Critical
Denote Foils where HTML is sufficient

1 Introduction to ActiveX, with VBScript
2 ActiveX with VBScript
3 What is ActiveX?
4 When to use ActiveX?
5 ActiveX Architecture
6 Writing a simple ActiveX example
7 Adding a Label Control
8 Adding a Button Control
9 The Script Wizard
10 Example VBScripts
11 Example web page
12 ActiveX
13 The <OBJECT> Tag
14 An Example Object Tag
15 Capabilities of ActiveX Controls
16 Downloading new controls from the web
17 The HTML Layout Control
18 VBScript
19 Basic Elements of VBScript Language
20 VBScript accesses document elements
21 VBScript Language Control Statements
22 Types and Expressions
23 Date, Time, and browser functions are built-in

Outside Index Summary of Material



HTML version of Basic Foils prepared 4 May 97

Foil 1 Introduction to ActiveX, with VBScript

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
4/23/97
Nancy McCracken
NPAC

HTML version of Basic Foils prepared 4 May 97

Foil 2 ActiveX with VBScript

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
This talk is designed to describe the capabilities of ActiveX with VBScript for people who know Java and JavaScript. It will give some examples and mention key features without getting into serious programming details.
Outline:
  • General discussion of features and comparison with Java/JavaScript
  • Simple example of preparing a web page using the ActiveX Control Pad to add some built-in controls and the Script Wizard to attach a built-in VBScript.
  • More details on ActiveX
  • More details on VBScript

HTML version of Basic Foils prepared 4 May 97

Foil 3 What is ActiveX?

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
ActiveX has similar functionality to JavaScript and Java in adding dynamic elements to web pages.
ActiveX is an extension of the OCX controls that are used to interface many Microsoft applications to each other and to the windowing system.
The controls are programmed in VBScript, which is a subset of Visual Basic, and is familiar to most Microsoft application programmers.
Reference: "ActiveX and VBScript", by Paul Lomax, Laura Lemay's Web Workshop, sams.net, 1997.

HTML version of Basic Foils prepared 4 May 97

Foil 4 When to use ActiveX?

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
One advantage to using ActiveX is the built-in authoring tools, both for adding elements (controls) to web pages and for any accompanying VBScripts.
The major disadvantage is that web pages using ActiveX are recognized only by Microsoft's Internet Explorer, so that they have a limited audience.
ActiveX would be particularly useful in a corporate environment that already had many applications and OCX controls programmed that would be connected by the web pages, and where the web pages are intended for intranet use, and not general internet use.
If your web page applications are starting from scratch or are intended for general internet use, then it would probably be better to use Java/JavaScript.

HTML version of Basic Foils prepared 4 May 97

Foil 5 ActiveX Architecture

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
ActiveX with VBScript combines many of the capabilities of JavaScript and Java:
  • ActiveX controls and VBScript subroutines are put right into the HTML pages.
  • They can directly access properties of the browser.
  • VBScript can also be used as a general object-oriented programming language.
Many useful ActiveX controls and VBScripts, such as using a button to control other elements of the web page, are "built-in" to the Internet Explorer. Other user-written controls would have to be downloaded to the client machine.
ActiveX controls reside directly on the client machine and do not have the same built-in security restrictions of Java/JavaScript. Before a control is downloaded a "Certificate Page" is presented to the user, giving information about the author or certifiying organization of this control. If the user trusts this author or organization, then he or she can continue the download.
  • At the JavaOne conference, Sun demonstrated how to write an ActiveX control that would wipe out the client's disk when downloaded!

HTML version of Basic Foils prepared 4 May 97

Foil 6 Writing a simple ActiveX example

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Run the ActiveX Control Pad to write HTML pages

HTML version of Basic Foils prepared 4 May 97

Foil 7 Adding a Label Control

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
object tag
use pop-up window to set label properties
html object tag is automatically generated
view box is "almost WYSIWYG"

HTML version of Basic Foils prepared 4 May 97

Foil 8 Adding a Button Control

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
The insert control menu lists built-in controls

HTML version of Basic Foils prepared 4 May 97

Foil 9 The Script Wizard

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
For each control, the script wizard lists events to select
Then you specify changes to properties of other elements

HTML version of Basic Foils prepared 4 May 97

Foil 10 Example VBScripts

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
uses the script tag with language VBScript
event subroutines are automatically generated

HTML version of Basic Foils prepared 4 May 97

Foil 11 Example web page

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Clicking the button changed the label
Mouseover the label added text to the status bar

HTML version of Basic Foils prepared 4 May 97

Foil 12 ActiveX

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
ActiveX controls are components that extend the capabilities of the web page. They were formerly known as OCX or OLE controls, Microsoft software development.
An ActiveX control can be programmed in a language such as Visual C++, Visual Basic or Delphi.
An ActiveX component is designed to be used by some other software (such as a web browser).
OLE controls interface applications to the windowing system.

HTML version of Basic Foils prepared 4 May 97

Foil 13 The <OBJECT> Tag

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
The <object> tag is proposed by the World Wide Web consortium to place an object on a web page. It would replace the current <img> and <applet> tags, as well as the DYNSRC attribute for audio and video, and other proprietary extensions to HTML.
Attributes of the object tag:
  • name
  • type
  • URL address
  • Layout information such as width, height, align, . . .
  • an ID code
Inside the object, the <param> tag can be used for parameters.

HTML version of Basic Foils prepared 4 May 97

Foil 14 An Example Object Tag

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
This creates a "spin button" control on the web page: <object id="SpinButton1" width=16 height=32 classid="CLSID:79176FB0-B7F2-11CE-97EF-00AA006D2776"> <param name="Size" value="423;846"> </object>
The classid says what kind of object it is (CLSID) and enough information for the browser to find the object on the user's Windows system, identify and run the control.
Parameters are used to set properties of the control.
The codebase property can be set to a URL if the control is a custom control that the user may need to download.

HTML version of Basic Foils prepared 4 May 97

Foil 15 Capabilities of ActiveX Controls

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Any control can be made into a hyperlink.
HTML elements are known as "intrinsic controls" and have additional attributes that you can attach scripts to.
  • For example, you can put general buttons on the page used to access or change form fields.
Similar list of events to JavaScript
  • For example, you can use mouseover to display link descriptions whenever the mouse is over a link.
For communicating with users, there are: Alert Boxes, Message Dialog Boxes, Confirm Boxes, Prompt Boxes, and Custom (Input) Dialog Boxes.
Build a drop-down menu on your web page.

HTML version of Basic Foils prepared 4 May 97

Foil 16 Downloading new controls from the web

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
A collection of ActiveX Controls is at the Microsoft ActiveX Gallery: http://www.microsoft.com/workshop/
Contains controls both from Microsoft and third-party vendors.
There is also an ActiveX plug-in for Netscape browsers running in a Windows environment.

HTML version of Basic Foils prepared 4 May 97

Foil 17 The HTML Layout Control

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
This control allows you to design the placement of other controls on the web page.
  • The Layout Control Tool brings up a grid window to place controls onto
  • and a Toolbox of controls to place
Includes all forms elements plus:
  • Command buttons, Tab Strips, Scroll Bars, Spin Buttons, Image Controls, and Hot Spots.
  • You can add your own controls to the Toolbox.

HTML version of Basic Foils prepared 4 May 97

Foil 18 VBScript

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
VBScript is similar in scope and functionality to JavaScript
It is a subset of Microsoft Visual Basic for Applications (VBA).
It can be used to interface both ActiveX controls and Java applets
It can also be used as stand alone scripts that act directly on browser objects.

HTML version of Basic Foils prepared 4 May 97

Foil 19 Basic Elements of VBScript Language

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Built-in data types include: Empty, Null, Integer, Long, Single, Double, Date, String, Object, Error
You may declare data types for variables, or you may leave it to the system to infer a type (variant type): <script language="vbscript"> <!-- Qty = 162 ProductName = "Paper Clip" --> </script>
A global variable is declared with the keyword dim: dim space dim myArray(9) creates a 10 element array indexed from 0 to 9

HTML version of Basic Foils prepared 4 May 97

Foil 20 VBScript accesses document elements

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Object-oriented view, shown in an example script to add the values that the user has typed into two textfields and display it in a third: Sub Button1_OnClick FirstData = CDbl(Document.Form1.Text1.Value) SecondData = CDbl(Document.Form1.Text2.Value) Document.Form1.Text3.Value = FirstData + SecondData End Sub
Note the Basic (and Fortran-like) syntax that statements are distinguished by being on separate lines.
Cdbl converts text input string to a double.

HTML version of Basic Foils prepared 4 May 97

Foil 21 VBScript Language Control Statements

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Example using a for loop and an if-then-else for a form with a set of radio buttons named choice1 (note that the loop covers all elements of the form named OrderForm): binSize = False for i = 0 to Document.OrderForm.Elements.Count -1 if Document.OrderForm.Elements(i).Name = "choice1" then if Document.OrderForm.Elements(i).Checked then binSize = True strSize = "Size: " & Document.OrderForm.Elements(i).Value exit for end if end if next

HTML version of Basic Foils prepared 4 May 97

Foil 22 Types and Expressions

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Notes on previous example:
  • = is both assignment and equality
  • Convention is to put type at beginning of variable names
  • & is string catenation
Continuing the example: if not binSize then alert "You must choose a size" end if

HTML version of Basic Foils prepared 4 May 97

Foil 23 Date, Time, and browser functions are built-in

From Introduction to ActiveX, with VBScript CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
These functions return the current date and time from the client machine: myDate = Date() myTime = Time()
In addition to various communication controls like alert boxes, you can write directly to the document: Document.Write = Document.LastModified

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Nov 29 1998