Client-side scripts
Up The Time is Now! Are you ready? Simple Validation Complex Validation Sign Guest Book Calculator Multiple Choice View Guest Book

Client-side scripts are usually written either in VBScript or JavaScript - VBScript is easier to write and it works well with Internet Explorer browsers but not with Netscape Navigator. This limitation of client-side VBscripts is a real problem because you can never know which type of browser is going to be used to view your pages. Despite the problem of using VBscript in client-side scripts we will concentrate on VBscript because the alternative, Javascript, is more difficult and matches less well the rest of this site.

Another disadvantage of client-side scripts is that they are incorporated directly into HTML code and are thus visible to anyone who cares to examine the source code - your scripts can thus be easily 'pirated'. To learn more about ASP and server-side scripts click HERE.

Making a client-side VBscript

Recall that there are 3 main stages to the production of a VB project:
    1) Create controls
    2) Set properties
    3) Write code


The first two stages are very much more limited in VBScript than in VB itself but the third stage, code writing, is very similar and almost as powerful as in regular VB, so very sophisticated code can be written.

Stage 1: Create the controls

The only controls that can be easily added to an HTML page are:

bulletOne-line textbox
bulletScrolling (multiline) textbox
bulletCheckbox
bulletOption button (Radio button)
bulletComboBox (Drop-down menu)
bulletCommand Button (Push Button)
bulletPicture

Note that there is no equivalent to the 'label' control in VB (there is a field called a 'label' but it has a different, very specific purpose). In fact, VB-style labels are not needed in VBScript because it is possible to type directly into the forms. Also, note that there is no Timer control available in VBScript.

Mr. Ward strongly recommends that you use Microsoft FrontPage or the less powerful Microsoft FrontPage Express to create your web pages, complete with VBScripts. In the following text, it is assumed that you are following this advice. In Microsoft FrontPage, controls (fields) can be inserted into the page while in 'normal' mode using the Form item in the Insert menu. By default MS FrontPage will automatically enclose all controls (fields) within a form, and may also give you unasked-for 'Submit' and 'Reset' buttons. But controls do not need to be inside a form, so let's keep it simple - turn off this annoying feature by going to Tools/Page Options/General and unchecking the box marked "Automatically enclose form fields within a form".  Note also that a web page can contain several forms with different names. 

Stage 2: Set properties

This is the biggest limitation of VBScripting, since most fields have very few properties that can be set without directly modifying the HTML code, such as
    1) Name
    2) Caption (called 'Value' in VBScript)
    3) Tab Order (as in VB, this is used to control the way that hitting the TAB key shifts the focus from one field to another).

In FrontPage, these 3 properties can be set by right-clicking the field and choosing the appropriate property. Ignore all the options in the properties dialog except the 3 mentioned here. The form itself has only one property of interest: its name, which can be set in the same way (it's a good idea to use 3-letter prefixes, as in VB).

Stage 3: Write code

As previously mentioned, VBScript code is almost as sophisticated and powerful as VB code, and can be used to make very useful applications. However, it is limited by 3 factors:
    1) It must work with the limited range of properties listed above
    2) The creators of VBScript wanted to make a language that runs at least as fast as the only competing scripting language, JavaScript, so the slower, more complex commands were removed
    3) Viruses in VBScript could potentially harm any computer that downloaded the infected page, so all the features of VB that could potentially be abused (such as file I/O) were also removed.

Samples

At the top of this page are links to some sample VBScript pages. They won't knock your socks off, but at least the scripts are easy to understand. The source code is given in every page but don't forget that in any scripted page you can always see the script by selecting the 'Source' option in the View menu of your browser. Study the code carefully...

 

The Time is Now! Are you ready? Simple Validation Complex Validation Sign Guest Book Calculator Multiple Choice View Guest Book

Up Next