PRB: Wrong Number of Arguments Error When Call Math Functions (129872)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q129872 SYMPTOMS
Adding 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.
CAUSE
All 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.
RESOLUTION
Use 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)
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 12/9/2003 |
---|
Keywords: | kberrmsg kbprb kbprogramming KB129872 |
---|
|