We help IT Professionals succeed at work.

Display two decimal places with decimal datatype

gogetsome
gogetsome asked
on
Medium Priority
1,351 Views
Last Modified: 2008-02-20
Hello, how can I display 2 decimal places when the datatype is decimal and I'm using the code below??
 Dim arrPercent(3) As Decimal
        arrPercent(0) = ((objDS.Tables(0).Rows(0).Item("Pitted")) / TotalPie * 100)
        arrPercent(1) = ((objDS.Tables(0).Rows(0).Item("Full Blast")) / TotalPie * 100)
        arrPercent(2) = ((objDS.Tables(0).Rows(0).Item("Repair")) / TotalPie * 100)
        arrPercent(3) = ((objDS.Tables(0).Rows(0).Item("New Condition")) / TotalPie * 100)
Comment
Watch Question

Commented:
You can format a decimal as a string for display using string.Format()

Dim iNum as Decimal = 0.7525
Dim strDisplay as String = String.Format("{0:F2}", iNum) ' display as 2 decimal places

Explore More ContentExplore courses, solutions, and other research materials related to this topic.