back up codes

always have a backup of your code

Archive for the tag “decimal round off”

number of fractional digits

The following code will round off the given decimal number into certain number of fractional digits.

The example below will round it to two fractional digits and display it in a label control:

Dim myDecimal As Decimal
myDecimal = Decimal.Parse(txtbxNumber.Text)
myDecimal = FormatNumber(myDecimal, 2, TriState.False)
lblNumber.Text = String.Format("The rounded number is equal to {0} ", myDecimal)

Post Navigation

Follow

Get every new post delivered to your Inbox.