Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid procedure call or argument Philosophaie Excel Programming 3 August 18th 09 10:43 AM
Invalid procedure call or argument salgud Excel Programming 1 January 12th 09 10:41 PM
Invalid procedure call or argument JE McGimpsey Excel Programming 0 January 12th 09 09:38 PM
Invalid Procedure Call Or Argument with VBScript [email protected] Excel Programming 0 November 28th 07 01:50 PM
Invalid Procedure call or argument T De Villiers[_58_] Excel Programming 1 July 25th 06 03:01 PM


All times are GMT +1. The time now is 08:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"