PRB: Wrong Number of Arguments Error When Call Math FunctionsLast reviewed: September 29, 1997Article ID: Q129872 |
The information in this article applies to:
SYMPTOMSAdding a reference to Microsoft Excel's Type Library from Visual Basic version 4.0 and then early binding an instance of Microsoft Excel's Application Object results in the following error message, when calling a Math function on that object:
Wrong number of arguments or invalid property assignment. CAUSEAll the math functions in the Microsoft Excel Type Library are typed as receiving no arguments, but most of them do have arguments. This is displayed in the help string for the corresponding math function in Visual Basic's Object Browser.
RESOLUTIONUse late binding with a generic object. For example, use the following code in the Form_Click event in the "Steps to Reproduce Behavior" section of this article:
Dim XLApp As Object Set XLApp = CreateObject("excel.application") z = XLApp.Atan2(3, 4) MsgBox Str$(z) STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
Keywords : IAPVBA VB4ALL VB4WIN vbwin GnrlVb kberrmsg kbprg Technology : kbole kbvba Version : WINDOWS:4.0 Platform : WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |