|
-
Apr 18th, 2008, 03:45 AM
#1
Thread Starter
Hyperactive Member
-
Apr 18th, 2008, 03:53 AM
#2
Thread Starter
Hyperactive Member
Re: Really Annoying Invalid Procedure Call or Argument
...and what is stranger still, is that my calculator has the same problem, so I am doing something fundamentaly stupid here, but my brain fart is now so big, my eyes have exploded.
-
Apr 18th, 2008, 03:59 AM
#3
Addicted Member
Re: Really Annoying Invalid Procedure Call or Argument
what are those variable types anyway??, as i saw on your declaration area, righttoprep1,righttoprep2 dont have any datatypes
so i think the system will assign it as a variant, i think by a small chance. try to add a data type on your declaration. if your trying to compute declare it as a double
vb Code:
Public RighttoPREP1 as Double,RighttoPREP2 as Double
and so as the other variable, depending on their usage
-
Apr 18th, 2008, 04:03 AM
#4
Addicted Member
Re: Really Annoying Invalid Procedure Call or Argument
and oh, i forgot, the program will accept data from textbox right?? try this
i think the problem is, the inputted data is red as a string and not a number so try to convert it to a number first.
vb Code:
RighttoPREP1=val(txtNo.text) 'to convert the inputted data into a number
RighttoPREP2=RighttoPREP1 ^ LoftExp
and oh, why are you converting the result into a string??
vb Code:
text1.text=str(RighttoPREP2)
text1.text=RighttoPREP2 'use this instead
i hope i helped you
Last edited by leinkyle; Apr 18th, 2008 at 04:10 AM.
-
Apr 18th, 2008, 04:36 AM
#5
Re: Really Annoying Invalid Procedure Call or Argument
From MSDN Documetation of ^ Operator
result = number^exponent
A number can be negative only if exponent is an integer value. When more than one exponentiation is performed in a single expression, the ^ operator is evaluated as it is encountered from left to right.
Looks like you'll have to remember the sign of RightoPREP1 and Abs() it in the calculation and then apply the original sign back to RightoPREP2.
Code:
Private Sub Command1_Click()
Dim intx As Integer
xBaseMax = 3
a = 8
xmax = 6.8
LoftExp = 1.2
RightoPREP1 = ((-xBaseMax * a * Abs((xe) - xmax)) / xmax)
intx = Sgn(RightoPREP1)
RightoPREP2 = Abs(RightoPREP1) ^ (LoftExp)
RightoPREP2 = RightoPREP2 * intx
End Sub
Last edited by Doogle; Apr 18th, 2008 at 04:44 AM.
-
Apr 18th, 2008, 05:15 AM
#6
Re: Really Annoying Invalid Procedure Call or Argument
 Originally Posted by Doogle
intx = Sgn(RightoPREP1)
RightoPREP2 = Abs(RightoPREP1) ^ (LoftExp)
RightoPREP2 = RightoPREP2 * intx
Although those 3 lines will prevent the error happens, but that is incorrect.
We cannot say: (-4)0.5 = Sgn(-4)*(Abs(-4))0.5 = (-1)*40.5 = -√(4) = -2
Because: (-4)0.5 = √(-4) is invalid on "Real" numbers.
Only you can have:
Code:
... ...
LoftExp = 1.2
RightoPREP1 = ((-xBaseMax * a * Abs((xe) - xmax)) / xmax)
If LoftExp = Int(LoftExp) Or RightoPREP1 >= 0 Then
RightoPREP2 = RightoPREP1 ^ LoftExp
Else
... ...
End If
-
Apr 18th, 2008, 01:10 PM
#7
Thread Starter
Hyperactive Member
Re: Really Annoying Invalid Procedure Call or Argument
leynkyle>
1. the data types are taken care of by the DefDbl A-Z statement.
2. No, the textbox merely reports the result from the computation.
Thank you for the response, however.
doogle, anhn>
AAAHHHH!!!...THANKS FOR RESETTING MY BRAIN! Now I see that it was a heiarchy issue. The varable, RightoPREP1 CONTAINED the (-) sign so vb operated it first as if it was in parentheses with the value, THEN calculated the exponent. But in the Immediate Window, vb could separate the (-) sign out and use the standard heirarchy rules to evaluate the exponent first, THEN the (-) sign.
Major, MAJOR brain fart. I just couldn't see the dumb error I was making. That's what happens when you work late. Thanks for the reboot.
-
Apr 18th, 2008, 02:27 PM
#8
Re: Really Annoying Invalid Procedure Call or Argument
Now that we've helped you, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer. Also if someone has been particularly helpful, or even particularly unhelpful, you have the ability to affect a their forum "reputation" by rating their post. Your rating won't actually count until you have 20 posts, but the person you rate will see it and know that you appreciate their help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|