• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1335
  • Last Modified:

Display two decimal places with decimal datatype

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)
0
gogetsome
Asked:
gogetsome
1 Solution
 
gnoonCommented:
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
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now