2

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
Keith
  • 20,636
  • 11
  • 84
  • 125
Jesse
  • 239
  • 6
  • 20

1 Answers1

4

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.

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
  • You better first check if it's numeric if you're going to use those cDbl/CLng/CInt, or they'll give errors if empty or null. – Control Freak Feb 15 '12 at 00:14
  • 1
    @zee: You are right of course bur that is just a tip of the iceburg, what should happen if the check finds a value is non-numeric? – AnthonyWJones Feb 15 '12 at 07:42