Click to See Complete Forum and Search --> : Type Mismatch error (this used to work though)


NevadaRon
07-24-2005, 02:29 AM
I am having the worst time with this piece of code. I know this used to work before, and I can not remember making any changes to the site or to the database.

<%
FOR i = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPRODUCTID, i ) <> "" THEN
orderTotal = orderTotal + ( localCart( CARTPRICE, i ) * localCart( CARTQUANTITY, i ) )
%>

I get an error on the last line of this code. I have put NAMETYPE commands just above this code, and every variable is INTEGER.

What else should I look at, already been stumped for a few hours.

Ron

buntine
07-24-2005, 03:44 AM
Print out the value of every variable.

What is the error your getting?

Bullschmidt
07-25-2005, 09:54 PM
And sometimes I need to wrap a variable in CInt() or CLng() or CDbl() to make sure it gets used as a number:

MyVar3 = CLng(MyVar1) + CLng(MyVar2)

buntine
07-25-2005, 10:59 PM
And the IsNumber function can help to prevent potential errors.

If IsNumber(MyVar1) Then
MyVar2 = CLng(MyVar1)
End If

Regards.