cdemott33
asked on
How to fomat a double in a textbox
I have currency values that are stored in my database as a double. I need to load these values into a textbox so they can be changed, but I want to round them up to 2 decimal places. How do I do this?
For example: Database value for ActualCost is 1436.9051
I want to round this up and display it in a textbox as 1436.91
I can't use the {0:c} because it adds the dollar sign.
Is there another format I can use to get this to work?
For example: Database value for ActualCost is 1436.9051
I want to round this up and display it in a textbox as 1436.91
I can't use the {0:c} because it adds the dollar sign.
Is there another format I can use to get this to work?
' This doesn't work becuase it add the $
m_tbActualCost.Text = String.Format("{0:c}", dt.Rows(0).Item("ActualCost"))
' What format can I use that will work?
m_tbActualCost.Text = Format(math.round(cdbl(dt. Rows(0).It em("Actual Cost")), 2), "##,##0.00")
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
try this,
decimal text;
text = 1.989m;
Label1.Text = String.Format("{0:#.##}", text);
decimal text;
text = 1.989m;
Label1.Text = String.Format("{0:#.##}", text);
ASKER
This pointed me in the right direction, but I had to use {0:F2} to get it to work correctly
Open in new window