Microsoft KB Archive/253282

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


Article ID: 253282

Article Last Modified on 6/28/2004



APPLIES TO

  • Microsoft Internet Explorer 4.0 128-Bit Edition
  • Microsoft Internet Explorer 4.01 Service Pack 2
  • Microsoft Internet Explorer 4.01 Service Pack 1
  • Microsoft Internet Explorer 4.01 Service Pack 2
  • Microsoft Internet Explorer 5.0
  • Microsoft Internet Explorer 5.01
  • Microsoft Internet Explorer 5.5
  • Microsoft Visual Basic, Scripting Edition 3.0
  • Microsoft Visual Basic, Scripting Edition 4.0
  • Microsoft Visual Basic, Scripting Edition 5.0
  • Microsoft JScript 3.0
  • Microsoft JScript 4.0
  • Microsoft JScript 5.0
  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 4.0 Enterprise Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition



This article was previously published under Q253282

SYMPTOMS

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.

CAUSE

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.

RESOLUTION

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.

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.

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

269258 INFO: JScript Passes Variables by Value


Keywords: kbnofix kbprb KB253282