Hi Roland,
To round, you use static method System.Math.Round(nNumber, nDigits)
dTotal = System.Math.Round(dPrice * dTaxRate,2)
To work with Textboxes, you need to use the Text property of the Textbox to extract the value entered in the control
dTotal = CDec(cbPrice.Text) * dTaxRate
>Can you set a textbox to a datatype?
Textbox.Text property must always be set to a string. You need to convert it to other data types when you extract it's value.
>Can you set a format to decimal with length 10 with 2 decimals?
To format textboxes, you need to use the techniques shown in message #
670154>Hi,
>
>How do you round a calculation like the following?
>
>dim dTotal as Decimal = 0
>dim dTaxPerc as Decimal = .0725
>dim dPrice as decimal = 0
>
>dTotal = dPrice * dTaxRate (Rounded to 2 deciaml places)
>
>Also, how do you add, subtract, divide using textboxes in forms?
>I have tried and get systax errors. cdec(cbPrice)
>
>Textbox cbPrice
>
>dTotal = cdec(cbPrice) * dTaxRate
>
>Whats the secret?
>
>Can you set a textbox to a datatype?
>Can you set a format to decimal with length 10 with 2 decimals?
>
>Thanks
>Roland
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi