[thelist] JScript v VBScript

Brian King BKing at Impact-Technologies.com
Wed Jan 30 07:59:00 CST 2002


Sorry, I am a bit late in replying to this.  I just wanted to point out that
Vbscript will work on all machines if you write the code to execute at the
server instead of the client machine.  If you are looking for client
compatibility, you will still run into trouble with JS with people who have
all client side script capability turned off.  Consider server side
scripting, which ever way you go.

Brian

-----Original Message-----
From: thelist-admin at lists.evolt.org [mailto:thelist-admin at lists.evolt.org]On
Behalf Of Michael Galvin
Sent: Tuesday, January 29, 2002 4:13 PM
To: thelist at lists.evolt.org
Subject: [thelist] JScript v VBScript

I have a little problem.  I've 'stolen' a bit of VBScript from a site which
works out the monthly financing on a motor loan.  It's written in VBScript,
so it only works on Windows machines (I assume - it certainly doesn't work
on IE Mac).

So I decided to convert it to JScript.  No problems technically, but there
seems to be a massive difference between how VBScript works out maths
figures and how JScript handles it.

VBScript:
MthFullCredit=int((Prin*MonthRate)/(1-(1+MonthRate)^(-1*NumPayments))*100)/1
00

JScript:
MthFullCredit=Math.ceil((Prin*MonthRate)/(1-(1+MonthRate)^(-1*NumPayments))*
100)/100;

Exact same code (apart from int becoming Math.ceil).  But the result of the
VBScript is 567.11, while JScript gives me -3.7!  Bit of a difference.  I've
narrowed it down to the

(1-(1+MonthRate)^(-1*NumPayments))*100

section of the code, for which VBScript gives 24.4 odd and JScript
returns -3600.  I assume it's the order in which the 2 languages do each
part of the calculation.  Does anybody know what I'm talking about, and help
me work out the order that VBScript uses so that I can 'force' JScript to do
the same thing...?

(Just so you know, I haven't a clue what the script is doing to work out
MthFullCredit, and every time I change it, it breaks)

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list