At the risk of sounding stupid

# Thread: At the risk of sounding stupid

1. Member
Join Date
Dec 1969
Posts
51

## At the risk of sounding stupid

I am going round in circles trying to get this formula to work. <BR><BR>gst = (setupprice + price) * (10/100) <BR><BR>If the values are <BR>setupprice = 15.00 <BR>price = 30.00 <BR><BR>gst should equal 4.50 but I am getting a value of 4,5 <BR><BR>&#039;Stupid genius&#039; Suggested cdbl, but I don&#039;t know what that means nor can I find any info on it.<BR><BR>PLease help

2. Senior Member
Join Date
Dec 1969
Posts
19,082

CDbl is filly explained in the VBScript docs at :<BR><BR>http://msdn.microsoft.com/scripting/<BR><BR>as are the basics of VBScript math.<BR><BR>j<BR>http://www.atrax.ws/

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## You've been misled...

YOu *ARE* getting the right answer!!!<BR><BR>Want to prove it?<BR><BR>&#060;%<BR>Response.Write "The number 4.50 appears as " & 4.50 & "&#060;HR&#062;"<BR>%&#062;<BR><BR>DO that on your ASP page.<BR><BR>You are, apparently, using a server computer that is located in some country where the "decimal point" character is a comma, instead of a period! (For example, Germany, if I recall correctly.)<BR><BR>And you do *not* need CDBL. Multiplying by (10/100) [or, more succinctly, 0.1] will *automatically* force VBS to use floating point arithmetic. You&#039;d have to work to make it not do so.<BR><BR>If you *need* to get a period as your decimal point, then change your locale to one that automatically does so. Such as the USA:<BR><BR>&#060;%<BR>Session.LCID = &H0409 &#039; USA -- &H0809 is UK, I think<BR>Response.Write "The number 4.50 appears as " & 4.50 & "&#060;HR&#062;"<BR>%&#062;<BR><BR>*NOW* see what you get!<BR><BR>Okay, you still aren&#039;t getting 4.50, are you? But that, too, is normal! VBScript *automatically* chops off leading and trailing zeros from numbers. <BR><BR>If you want a number displayed with a certain number of digits after the decimal point, you need to use the VBS function "FormatNumber".<BR><BR>Or, since you say this is for GST, maybe you really want "FormatCurrency", which will *automatically* use the proper currency symbol for the locale the you specify via Session.LCID.<BR><BR>But the problem is most certainly *not* the math.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•