Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Invalid procedure call or argument.
This worked in the upper part of my program with different parameters:
CL(k + 1) = (1 - Math.Cos(zL(k + 1) ^ 0.5)) / zL(k + 1) previously worked as: C(k + 1) = (1 - Math.Cos(z(k + 1) ^ 0.5)) / z(k + 1) They were in a loop interrupted by an "if" and a "goto" Run-time error "5": Invalid procedure call or argument. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Invalid procedure call or argument.
I can't give you an answer without know the the vaules of all the variables.
If you are passing a string (not numbers) to the cosine function that would give this error. I would look at the array xL and make sure it contains numbers and that the array has data at the index K+1. "Philosophaie" wrote: This worked in the upper part of my program with different parameters: CL(k + 1) = (1 - Math.Cos(zL(k + 1) ^ 0.5)) / zL(k + 1) previously worked as: C(k + 1) = (1 - Math.Cos(z(k + 1) ^ 0.5)) / z(k + 1) They were in a loop interrupted by an "if" and a "goto" Run-time error "5": Invalid procedure call or argument. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Invalid procedure call or argument.
zL(k+1) never equals zero and if it does I have a if then loop around it.
Even with this protection the error occurs. zL(k+1) does however goes negative and you can't take the square root of a negative number so: If zL(k + 1) < 0 Then If zL(k + 1) 0 Then CL(k + 1) = (1 - Math.Cos(zL(k + 1) ^ 0.5)) / zL(k + 1) SL(k + 1) = ((zL(k + 1) ^ 0.5) - Math.Sin(zL(k + 1) ^ 0.5)) / zL(k + 1) ^ (3 / 2) Else CL(k + 1) = (1 - Application.WorksheetFunction.Cosh(-zL(k + 1) ^ 0.5)) / zL(k + 1) SL(k + 1) = (Application.WorksheetFunction.Sinh(-zL(k + 1) ^ 0.5) - (-zL(k + 1) ^ 0.5)) / (-zL(k + 1)) ^ (3 / 2) End If Else MsgBox ("z(k+1) can't divide by zero.") End If And the error switches to the new cosh added. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Invalid procedure call or argument.
Cos and Cosh will except any real number positive or negative as well as
zero. Adn VBa doesn't have an imaginary nor complex variable type. Threfore, the problem must be that the value is nothing. In VBA if you don't write to a location in an array or variable the initial value is NOTHING which will genrate the error you are getting. try adding the following to your code Dim Zl(100) as single 'or the size you need make surew you include a type like 'single, double Erase Zl 'sets array to zero "Philosophaie" wrote: zL(k+1) never equals zero and if it does I have a if then loop around it. Even with this protection the error occurs. zL(k+1) does however goes negative and you can't take the square root of a negative number so: If zL(k + 1) < 0 Then If zL(k + 1) 0 Then CL(k + 1) = (1 - Math.Cos(zL(k + 1) ^ 0.5)) / zL(k + 1) SL(k + 1) = ((zL(k + 1) ^ 0.5) - Math.Sin(zL(k + 1) ^ 0.5)) / zL(k + 1) ^ (3 / 2) Else CL(k + 1) = (1 - Application.WorksheetFunction.Cosh(-zL(k + 1) ^ 0.5)) / zL(k + 1) SL(k + 1) = (Application.WorksheetFunction.Sinh(-zL(k + 1) ^ 0.5) - (-zL(k + 1) ^ 0.5)) / (-zL(k + 1)) ^ (3 / 2) End If Else MsgBox ("z(k+1) can't divide by zero.") End If And the error switches to the new cosh added. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Invalid procedure call or argument | Excel Programming | |||
Invalid procedure call or argument | Excel Programming | |||
Invalid procedure call or argument | Excel Programming | |||
Invalid Procedure Call Or Argument with VBScript | Excel Programming | |||
Invalid Procedure call or argument | Excel Programming |