Run math on asp variables without getting type mismatch
-
29-04-2021 - |
Domanda
I'm trying multiply discount_v times item_qty + total_discount but i keep getting the error Microsoft VBScript runtime error '800a000d' Type mismatch.
Can anyone tell me what I'm doing wrong, please! Here is the code I am using:
total_discount = (discount_v * item_qty) + total_discount
Soluzione
Try this:
total_discount = (CDbl(discount_v) * CInt(item_qty)) + CDbl(total_discount)
Better yet use these type conversion functions when you initially assign the variables.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow