VBScript - No Real Math?? FORGET MICROSOFT??? Go Java?? 
Author Message
 VBScript - No Real Math?? FORGET MICROSOFT??? Go Java??

This is real frustrating.
In JavaScript I Use:
Myvar = Math.pow(.005, 2)
I get  .000025

If I use in VBScript
I get some long number with an E factor.

I'm trying to calculate Loan payments. The Javascript comes up with the same
thing as my Real Estate calculator. VBScript is out to lunch. It overshot
the payment ($160000 at 6% for 30 years) by over a hundred dollars.
The calculation in Java is:

It works.

In VBScript I used
It got just a hair closer if I used CDbl(MonthRate) first. I tried dropping
the Int, making it a double, etc. etc., etc. That's garbage, it's already a
variant. It still didn't get it right. Infact it changed the number very
little (but some).

The results aren't even close to the same. As shown above, I nailed it down
to apparantly VB can't really do powers in any detail. Garbage.

If I'm right, I'm going to study Java & C++ (Borland) much harder, forget
about Microsoft Certification and basically try to get away from Microsoft
completely. I've put years into VB. If it can't do math, I don't have any
more use for it and that would be downright disgusting.

So, MS gurus, can you help me? Can VB do real math? Or do I rewrite this
whole application in JavaScript and go with a competitor's Internet Server?

Marl Atkins

Microsoft Certified Professional
SoftLink Systems

Sat, 14 Jul 2001 03:00:00 GMT  
 VBScript - No Real Math?? FORGET MICROSOFT??? Go Java??


>This is real frustrating.
>In JavaScript I Use:
>Myvar = Math.pow(.005, 2)
>I get  .000025

Using a Math object is declares the input elements type.  So, in VBScript
you need to convert all the variants you are using.

>If I use in VBScript
>I get some long number with an E factor.

I would check your inputs that you are giving to the Exponent function.
Normally MS is pretty lax in their stringency, therefore developers have
more freedom (it also allows them to make more errors).  It is apparent that
you have abused this freedom.  The following code works splendidly:

dblBase = Request.Form("Base")
dblPower = Request.Form("Power")
If IsNumeric Request.Form("Base") And IsNumeric Request.Form("Power") Then
    dblResult = CDbl(dblBase) ^ CDbl(dblPower)
    dblResult = "Invalid Base or Power Input"
End If
Response.Write dblResult

Therefore it is not an error with VBScript, but rather with your

>Marl Atkins

>Microsoft Certified Professional
>SoftLink Systems

Sun, 15 Jul 2001 03:00:00 GMT  
 VBScript - No Real Math?? FORGET MICROSOFT??? Go Java??

I get "0.000025".  Isn't that right?

       Attached is a loan calculator that I use which uses VBScript. I didn't
    write it (Paul McFedries, author of some of the Unleashed! books from SAMS
    Press, did.) Does it get any closer to the right value?


    >This is real frustrating.
    >In JavaScript I Use:
    >Myvar = Math.pow(.005, 2)
    >I get  .000025
    >If I use in VBScript
    >I get some long number with an E factor.
    >I'm trying to calculate Loan payments....

Wed, 18 Jul 2001 03:00:00 GMT  
 [ 8 post ] 

 Relevant Pages 

1. Java conversion to VB app - Math.Pow

2. Trig Math functions gone haywire

3. Calling Java Classes from a Java jar library from VBScript

4. VB6 - Java - Microsoft

5. Math funtions using vbscript

6. Real real basic question ...

7. ICP going going gone

8. ** GO checkout Microsoft's Internet area

9. Where did Microsoft.XMLHTTP go ?

10. Java's Bean Scripting Framework (BSF) and VBScript

11. Java and VBScript simultaneously??

12. calling java classes in vbscript


Powered by phpBB® Forum Software