Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: Changes to ByRef Parameters in Script Event Handlers Are Not Passed to Controls

View products that this article applies to.

This article was previously published under Q253282

↑ Back to the top


When a Visual Basic ActiveX control fires an event that is handled in script, changes that are made to the event's ByRef parameters are not passed back to the control.

↑ Back to the top


The default OLE Automation Marshaller cannot convert a strongly-typed ByRef parameter into a ByRef Variant, so it converts the parameter into a normal ByVal Variant, and passes that to the scripting engine.

↑ Back to the top


To allow Visual Basic Script (VBScript) event handlers to change parameter values of events that are fired by Visual Basic ActiveX controls, declare the parameters as ByRef Variants. JScript event handlers are only able to change the values of these ByRef Variants if they contain Object references, because JScript passes all variables by value (not by reference), in accordance with the ECMA-262 specification.

↑ Back to the top

More information

Many of the controls that are included with Visual Basic have events that use strongly-typed (nonvariant) ByRef parameters. For example, the Microsoft DataGrid Control has a ByRef Cancel parameter for its BeforeColUpdate event.

Due to their popularity in Visual Basic, these controls are also widely used in Web pages. Most of these controls, however, were not designed for this environment, and you should consider this limitation before you use any of these controls in a scripting context.

↑ Back to the top


For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
269258� INFO: JScript Passes Variables by Value

↑ Back to the top

Keywords: kbnofix, kbprb, KB253282

↑ Back to the top

Article Info
Article ID : 253282
Revision : 3
Created on : 6/28/2004
Published on : 6/28/2004
Exists online : False
Views : 409