Click to See Complete Forum and Search --> : ASP Math?
txmail
09-17-2003, 10:26 PM
Ok, it might just be because I am really tired as it is late, but I cannot figure out why this will not work:
total2 = price12 + price22 + price32 * amount1
If I take the multiplication away it works fine, but add the multiplication and it bombs with:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: ""]'
/booker/engine1.asp, line 148
I have just been testing this on a form, nothing is contained in the pages, just empty form fields (that is where the values are coming from).
Thanks!
txmail
09-17-2003, 10:28 PM
This is how all the variables are declared (I am not using option explicit, yes I know this is bad pratice but I save that for after I get everything running).
price11=request.form("price11")
response.cookies("price11")=price11
price12=request.form("price12")
response.cookies("price12")=price12
and so on to fill the rest of the values...
Ribeyed
09-18-2003, 12:52 PM
hi,
the error message is saying that amount1 is of data type string. Doesn't matter if the value is 1, 2, 3, 4 etc. the data type of the variable amount1 is a string. I would try this:
total2 = price12 + price22 + price32 * int(amount1)
which would make the datatype for amount and integer.
hope this helps
txmail
09-18-2003, 09:49 PM
Tried that allready, still get same error. * is for multiplication right or am I missing something?
Ribeyed
09-18-2003, 10:17 PM
hi,
yes i think you are missing something.
price1 = 10
price2 = 20
price3 = 30
amount1 = 5
total = price1 + price2 + price3 * amount1
ok this works for me fine.
I know the values aren't comming from the form but that point is the calculation syntax is not the problem, its the datatype of the values you are passing to the calucation. One of the 4 or even all of the 4 are of datatype string when they all need to be int. You need to check this,
price1 = 10
price2 = 20
price3 = 30
amount1 = 5
total = int(price1) + int(price2) + int(price3) * int(amount1)
have you tried something like the above?
txmail
09-18-2003, 10:37 PM
I just tried this and still have the same error:
total1 = int(price11) + int(price21) + int(price31) * int(amount1)
total2 = int(price12) + int(price22) + int(price32) * int(amount2)
total3 = int(price13) + int(price23) + int(price33) * int(amount2)
total4 = int(price14) + int(price24) + int(price34) * int(amount2)
total5 = int(price15) + int(price25) + int(price35) * int(amount2)
total6 = int(price16) + int(price26) + int(price36) * int(amount2)
Ribeyed
09-18-2003, 10:59 PM
ok i have told you what the error means.
i have told you why you get that type of error.
I have tested code for you and have the code working here.
I'm sorry but i can't help you any futher than that.
rdoekes
09-19-2003, 08:31 AM
are there any empty variables? You cannot use empty variables in your calculation.
This is worth a try:
Function ConvertToValues(varValue)
If Len(varValue) = 0 Then
ConvertToValues= 0
ElseIf Not isNumeric(varValue) Then
ConvertToValues= 0
Else
ConvertToValues = CDbl(varValue)
End If
End Function
Hope this helps,
-Rogier Doekes