Chapter 7 - Modifications/Corrections/Additions

The examples in this chapter use VBScript for the ASP page scripting. VBScript has only one datatype, Variant. However, an ASP Visual Basic component can be developed using other datatypes as parameters such as String or Integer types. When values are passed from the script to the component, conversion between the Variant datatype in VBScript and the component datatypes are handled automatically. You do not have to specify "Variant" as the data type within the Visual Basic component.

In Example 7-2, the first parameter in each of the component's methods is passed by reference to demonstrate the two passing methods with VB. However, as this value is not changed, and as a constant is passed as the argument, the parameter should have been marked with the ByVal modifier. Not doing so may generate an error with certain environments, such as with PWS on NT Workstation.

In addition, all arguments passed by reference should be set to Variant data type when the component could be accessed with VBScript.

Also with Example 7-2, the methods do not show a specific return value type delimited by the keyword "As". When the function return type is not specified, it is set as a Variant data type by default.


In the error handling section, mention was made that the vbObjectError is not available within the script block. This isn't accurate, at least within an IIS 4.0, NT SP 4.0 environment, and vbObjectError can be used within ASP scripting blocks.

An example of using vbObjectError within a component and then processing this from an ASP scripting block has been demonstrated in a new code example. The component can be found in VB project dhtml3.vbp, the component is dhtml3.dll and the testing Web page is third.asp.

The vbObjectError constant is used to set a base for the error:

Const INVALID_BROWSER = 1

If browser > 1 Or browser < 0 Then
    Err.Raise Number:=INVALID_BROWSER + vbObjectError, Description:="Invalid Browser Number"
End If

The constant is then used to find the error value within the scripting block:

  If Err.Number = vbObjectError + INVALID_BROWSER  Then 
     Response.write("")
     Err.Clear
  End If

In addition, the On Error Resume Next error handling statement is used to allow processing of the page to finish.


Microsoft has changed its Web site, and many of the links listed in the chapter have changed.

Change the Further Reading entries from: