working out vat

1. Member
Join Date
Dec 1969
Posts
98

## working out vat

I have the following code in my shopping site<BR><BR>&#060;% <BR>Dim priceexvat, vat, priceinvat<BR>priceexvat = man("listprce")<BR>priceexvat = CInt(priceexvat) &#039or CLng<BR>vat = priceexvat * 17.5/100<BR>vat = Round(vat, 2)<BR>priceinvat = priceexvat + vat<BR>%&#062;<BR><BR>I am having problems with it though, quite hard to explain but here goes.<BR><BR>If I take out this line<BR>&#039priceexvat = CInt(priceexvat) &#039or CLng&#039<BR>and call &#060;% = priceecvat %&#062; somewhere on the page, its works great, but as soon as I add that line (which I need to to work out the vat) for some odd reason it decides to bring the price down by an average of 18p (changes depending on the inital cost)<BR><BR>Its really annoying, does anyone know how to fix this or a better way of working out the vat.<BR><BR>Thanks very much<BR><BR>Caroline

2. Mr Swifty Guest

## RE: working out vat

The function CInt rounds numbers. So CInt(20.18) will give you 20. So what you need to find out is how to get the value in the right type without cutting off the decimal places.

3. Mr Swifty Guest

## RE: working out vat

Try :<BR><BR>CCur(priceexvat)<BR><BR>...which converts it into the Currency data sub-type.<BR>By the way, " &#039CLng " is just a comment. Anything after a single quote is ignored when the script is run.

4. Member
Join Date
Dec 1969
Posts
98

## RE: working out vat

Cheers Mr Swiftly<BR><BR>Do I add this aswell as the CInt bit or instead of?<BR><BR>Thanks

5. Mr Swifty Guest

## RE: working out vat

Caroline<BR><BR>Both CInt and CCur convert a value into a numeric sub-type, so that it can be operated on arithmetically, so you only need one, which in this case has to be CCur.<BR><BR>So:<BR><BR>priceexvat = CCur(priceexvat)<BR><BR>...replaces the troublesome:<BR><BR>priceexvat = CInt(priceexvat)<BR><BR>PS. It&#039s very useful to know what&#039s actually going on here; it saves time down the line.<BR>

6. Member
Join Date
Dec 1969
Posts
98

## RE: working out vat

I just added it without the CInt and get this error<BR><BR>Variable uses an Automation type not supported in VBScript: &#039CCur&#039 <BR><BR>and with it I get <BR><BR>CatalogDisplay error &#039 800a01ad&#039 <BR><BR>ActiveX component can&#039t create object <BR><BR>/Product.ASP, line 50 <BR><BR><BR>any ideas?<BR>thanks alot.<BR><BR>Caroline

7. Member
Join Date
Dec 1969
Posts
98

## Thank you Thank you!!

Brilliant, totally works now,<BR><BR>and I&#039m gonna learn now exactly what it does.<BR><BR>thanks so much

8. Mr Swifty Guest

## RE: working out vat - ideas, anybody?

That&#039s a shame. CCur works with me, so I don&#039t know what&#039s wrong, and I wouldn&#039t like to venture a guess. I hope there&#039s someone out there who can solve this problem!<BR><BR>

9. Simhan Guest

## RE: working out vat

May you can try it with CDbl instead of CInt

#### Posting Permissions

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