Wednesday 15 April 2009

Math.Log in VBScript

Today I was working on an old Classic ASP project, and I was converting some JavaScript code to ASP.

Part of the code used the JavaScript Math.Pow function, e.g. Math.Pow(4,3), and I needed to do this in classic ASP.

I found that the ^ operator in VBScript does this, but it wasn't easy to transpose into my code, so I just added the following function to the page:

FUNCTION Pow(val, val2)
Pow = val ^ val2
END FUNCTION

Added called it as needed, e.g. Pow(4,3)

2 comments:

  1. Thank you for your timely post. I am taking a beginning ASP class and have to convert a javascript project to vbscript. There is a math.pow in the old script and your site just let me know how to handle it. Awesome,

    Cheri

    ReplyDelete
  2. That's no problem at all. You might want to look at http://www.w3schools.com/VBscript/vbscript_ref_functions.asp as well, as they list the ones that are already built into vbscript.

    ReplyDelete