## 8 replies

Last post Mar 24, 2009 01:17 PM by BmoreFinest

• joellevi

Member

11 Points

27 Posts

### Convert to two decimal places

How can I convert the Tax in the following code which is Double to a two decimal place figure

Public Shared Function GetBuyNowButton(ByVal itemName As String, ByVal itemNumber As String, ByVal price As Double, ByVal tax As Double, ByVal shipping As Double, ByVal userName As String) As String

Please hel I have tryied everything I knew, am also new to VB.

Thanks

vb.net VB ASP.NET

• StrongTypes

Contributor

6294 Points

5754 Posts

ASPInsiders

### Re: Convert to two decimal places

You can use Math.Round.

Math.Round(value, 2)

• joellevi

Member

11 Points

27 Posts

### Re: Convert to two decimal places

See I am learning VB and tryied the Math.Round but it created errors must be to with my syntax. Can you please tell me how extactly to write it?

Thanks.

• StrongTypes

Contributor

6294 Points

5754 Posts

ASPInsiders

### Re: Convert to two decimal places

What was the error you were getting?
• joellevi

Member

11 Points

27 Posts

### Re: Convert to two decimal places

Is this how to change it ?

Public Shared Function GetUploadCartUrl(ByVal TaxAmount As Math.Round(TaxAmount, 2), ByVal Subtotal As Double, ByVal ShippingAmount As Double) As String

The error is this:

Line 55:     ''' <param name="ShippingAmount"></param>
Line 56:     ''' <returns></returns>
Line 57:     Public Shared Function GetUploadCartUrl(ByVal TaxAmount As Math.Round(TaxAmount, 2), ByVal Subtotal As Double, ByVal ShippingAmount As Double) As String
Line 58:         Dim cart As ShoppingCart = ShoppingCartManager.GetCart()

• StrongTypes

Contributor

6294 Points

5754 Posts

ASPInsiders

### Re: Convert to two decimal places

Don't do the Math.Round in the method signature. Do it in the body of the method.

• joellevi

Member

11 Points

27 Posts

### Re: Convert to two decimal places

Can you please guide me how to put it?

Thanks

• joellevi

Member

11 Points

27 Posts

### Re: Convert to two decimal places

How do I write in the Body of the method?

Thanks

• BmoreFinest

None

0 Points

6 Posts