Optional Parameters in ASP

Question:
In my Visual Basic ActiveX DLLs, some of the methods that I created for my objects use optional parameters. When I attempt to call these methods, I receive a syntax error from IIS. I have tried referencing the method using both of the following methods:

   myObject.Load( ,Param2Val)

and

   myObject.Load(Param2 := Parma2Val)

I have tested this object and successfully called it using Visual Basic, so I was wondering if this problem is VBScript specific. Any ideas?

Answer:
It’s not so much a problem with VBScript as it is a designed behavior. Since VBScript was originally intended for use on the Web, it is “lighter” and provides fewer features than does its full-grown VBA counterpart.

In your first example, you might consider writing the object method so that it treats empty parameter strings the same way as it treats missing parameters. For example, inside of the method you might write:

If (IsMissing(Input)) or (Len(InputParam) < 1) Then...

This would enable you to make the call in ASP as

myObject.Load("",Param2Val)

As for your second example, you should call it without the parameter name as follows:

myObject.MyMethod(Parma2Val)

Again, this behavior is by design, as VBScript is not intended to work in exactly the same way as Visual Basic for Applications.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may