Search code examples
vbscriptasp-classic

vbscript minus operator marked as invalid character


I have a very simple equation in vbscript/asp. I get error on minus operator. I even had to add 0 in start of equation because I got same error at first one too.

y = 0 - (0.0114 * (x^2)) − (0.2396 * x) + 112.57

Microsoft VBScript compilation error '800a0408'

Invalid character

y = 0-(0.0114 * (x^2))-(0.2396 * x)+112.57

----------------------------^


Solution

  • The character between the x^2)) and the (0.2396 does not look like the character between the 0 and the (0.0114. It is likely an en dash, not a minus/hyphen. Fix that. Do not use Word or other word processor for creating code; the smart replacement of dashes and quotes will cause problems with code. Use a text editor like Notepad or Notepad++ instead.