how do i keep a value with 2 integers following a decimal point?

 Hi All.

I have a number like 0.50 i.e a value representing money in a double variable.However, it loses the last 0 and i am left with 0.5. I am using the formatCurrency function but still no luck. The problem is when i display the value stored, it only displays at 0.5 not 0.50. Any solutions?

Thanks 

0
aspd
8/22/2008 12:57:00 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

2 Replies
517 Views

Similar Articles

[PageSpeed] 23

How many parameters are you passing to FormatCurrency()? The second parameter, which is optional, specifies the number of decimal places to display. I looked here: http://msdn.microsoft.com/en-us/library/3352e6f5(VS.80).aspx

Try FormatCurrency(moneyAmount, 2)

Hope this helps.

EDIT: The link was to the VBscript version of the function. I changed the link to point to the VB.NET version.


Don't forget to mark a reply as "Answer" if it helped solve your problem. This will help others who have a similar problem find the answer quicker.
0
anphme
8/22/2008 1:28:45 PM

You can do

decimal.ToString("C2");

for currency symbol and 2 decimal places, or:

decimal.ToString("N2");

for just the 2 decimal place, no symbol
 

0
Lokira
8/22/2008 1:34:53 PM
Reply:

Similar Artilces:

How to validate a decimal value with 2 digits after decimal point (de decimal point is a comma)
  I am a newbee, I have a Textbox where de user must write the price of an object. How can I validate de data entry in the Textbox (it must be a valid decimal with 2 digits after decimal point), and my pages are in  Portuguese so the decimal point to be accepted must be a comma   thanks  well you can do something like followig:  suppose TextBox1.Text = 123456,789 then you can say if(TextBox1.Text.Contains(",") ) {     int index1 = TextBox1.Text.IndexOf(",") +1;     int index2 = TextBox1.Text.IndexOf(...

Keeping DBEdit value to 2 decimal point
How can I prevent the DBEdit from accepting more than 2 decimal points? I have a situation that the DBEdit gets an amount like 2.675 and at exit, it gets rounded up to 2.68. We need this to alert the user and not round the amount at exit, or not accept more than 2 decimal points to begin with. Any suggestion is appreciated. what about regular expressions? ^[0-9]*[.,]?[0-9]{0,2}$ I haven't test the expression so you have to find it by your self. > {quote:title=Deborah Sassounian wrote:}{quote} > How can I prevent the DBEdit from accepting more than 2 decimal points? &g...

how can I get an integer value out of a division that returns a decimal? (get the 1 out of 1.71564)??
I know I am doing somthing wrong because I am not geting the result I want out of this function:Dim week As Integer = Convert.ToInt16((year + dat.DayOfYear + baseday) / 7) I just want to know which week of the year it is which should only be an integer, but as you see I doo a division of the Day of year by 7 which returns 6 times out of 7 a decimal value can anyone help? The DateTime class has functions to do this for you.  I forget the name but look in there.Solutions Architect Coden Enterpriseshttp://www.codenenterprises.com/iblog get week of the year   DateTime d...

how to convert value with decimal point into value with decimal comma
Hello,  I like to know how I can change (for example) the value 55.55 into 55,55. (The system in my country is using comma's instead of points) I'm starting with  a string with the value "55.55" Then I will convert it to a double 55,55 Do I need the the system.Globalization namespace or is there just a simple solution?               Hi,If you are just going to use this format for display then it would be easy to do this:double dTemp;dTemp = 55.55;Response.Write(dTemp.ToString().Replace(".",","));H...

2 Decimal point value Problem..
Hi guys, Need help! How to create a DBF table with Floating Point column (2 Decimal Places) in Delphi code? Thanks. Regards, Eric coiner roy wrote: > Hi guys, > > Need help! > How to create a DBF table with Floating Point column (2 Decimal > Places) in Delphi code? Thanks. > > > Regards, > Eric Which Delphi version? Which Database components? No problems with creating other kinds of dbf-tables or columns? Tiedo -- ...

CompareValidator fail if currency value more than 2 decimal point
Does anyone encounter problem using the compare validator against a textbox with operator=DataTypeCheck, type="Currency" and the textbox value contains more than 2 decimal point? With type="Double" it works fine with more than 2 decimal point but must not have comma. Below is my test result: Currency 10,200.20 pass Currency 10,200.204 fail Double 10,200.20 fail Double 10200.204 pass Any suggestion to overcome this issue? Leon ...

how to get values from first two paragraphs in vb.net 2.0
hi all , i'm using vb.net 2.0. i want to get values from a textbox1's first or second para's . That is if the first para is less that 200 i want to get second para and show the first two para's in the textbox2 other display only the first para's in textbox2.  Please tell me how to get these..Thanks SwapnaPlease click "mark as answer" if this post helped you. Please be a little more clear, the text is confusing. sounds like the string needs to be searched for a number of spaces for a location to be split by and then sent to text boxes  D...

Getting lowest integer value in an array of integers
Hi, the subject pretty much says it all. Is there a function in vb.net that runs through an array of integers and grabs the lowest number? Thanks in advance. you can use Array.Sort() and then just access the first integer (although it may put the smallest integer in arr[0] not arr[1]) or you can write your own int i = arr[0]; for (int j=0; j<arr.Length;j++) if(arr[j]<i) i=j; I'm not sure how that translates to VB if you need to start from 1 or 0 thanks bsaperst, will give that a go....

[Bugzilla 3.0.2]: keep getting index.cgi: Use of uninitialized value in substitution (s///) ...
Hi Folks, I always see the message below when I start bugzilla. ================== [Thu Jan 10 14:45:36 2008] index.cgi: Use of uninitialized value in substitution (s///) at (eval 42) line 44. [Thu Jan 10 14:45:36 2008] index.cgi: Use of uninitialized value in substitution (s///) at (eval 42) line 44. [Thu Jan 10 14:45:36 2008] index.cgi: Use of uninitialized value in substitution (s///) at (eval 42) line 44. ================== Here is my setup OS = WIN XP + SP2 IIS V6.0 Bugzilla : v3.0.2 Regards, Sean Sean wrote on 1/10/08 11:51 PM: > Hi Folks, > >...

I keep having trouble with my email; it seems to have started when I installed Mozilla Firefox. Since I can apparently get no help, my ony choice is to uninstall it. #2
Name: Email: djfrohnAyahoodotcom Product: Firefox Summary: I keep having trouble with my email; it seems to have started when I installed Mozilla Firefox. Since I can apparently get no help, my ony choice is to uninstall it. Comments: I keep having trouble with my email; it seems to have started when I installed Mozilla Firefox. Since I can apparently get no help, my ony choice is to uninstall it. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 YFF35 Firefox/3.6.10 MindQuizSearchToolbar/1.2 From URL: http://hendrix.mozilla...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

How to get decimal value?
Hiie, i have this part of the query. i used sum(oranges)/sum(apples), but the value i get is always in a whole number and its already rounded for me, which i dun wan, i wan a decimal value instead. example: 24/5 = 4.8 but the above query i have will give me a 4 instead. so how should i modify the query to get 4.8 instead? Thanks for any help. Try this to force floating point instead of integer math: 24.0 / 5.0Steve Wellens My blog Thanks for the reply. But my sum(oranges) is the sum of total from a column. so i cant 'hardcode' the value. meanin i have a column orang...

getting started #2
Name: Dave Johnson Email: johnsonatfuntechdotcom Product: Minefield Summary: getting started Comments: Just installing for the 1st time Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2pre) Gecko/20070122 Minefield/3.0a2pre ...

How to get started #2
I was a php lover before. I must learn ASP.NET because my boss call for it. How can I get started and what books are suitable for the novices? Thanks Buy this book http://www.amazon.co.uk/exec/obidos/ASIN/067232542X/qid=1101093518/sr=1-1/ref=sr_1_2_1/026-0119114-1138034 Easy to understand - what's up with that ur name ?...

Web resources about - how do i keep a value with 2 integers following a decimal point? - asp.net.getting-started

The GOP Establishment Has Found The One Thing That Can Make Donald Trump Palatable: Ted Cruz
Huffington Post The GOP Establishment Has Found The One Thing That Can Make Donald Trump Palatable: Ted Cruz Huffington Post The Republican ...

ESPN exec: Sling TV 'significant' but Apple is 'frustrated'
ESPN has come of age in the cable era, but as internet TV grows and cord-cutting continues, its future is suddenly fuzzy. President John Skipper ...

Inspector General: Hillary Clinton’s Emails Contained Highly Classified Intel
Hillary Clinton’s emails are like a ghost that just won’t stop haunting her. For several months now, the former Secretary of State has been forced ...

Star Wars Toys Brought in $700 Million in 2015
Star Wars toys were the hottest property in the toy industry last year, generating hundreds of millions of dollars of sales, according to new ...

Governor's Emails Show Debate Over Blame for Flint Water
Emails released by the Michigan governor show that Rick Snyder's chief of staff told him last fall that the "real responsibility" for the Flint ...

Astronomers' findings point to a ninth planet, and it's not Pluto
Los Angeles Times Astronomers' findings point to a ninth planet, and it's not Pluto Los Angeles Times This artist's conception illustrates ...

Mumbai records year’s coldest day
The minimum temperature recorded is more than four degrees below normal, making it one of the coldest days recorded in the city this month.

Cheap Oil, Good for Consumers, Is Slamming Stocks. Why?
A plunging price of oil is dragging stock markets to their worst start to a year ever, even though low fuel prices are great for consumers and ...

WWE Rumors: Daniel Bryan Returns, AJ Styles Debuts, ‘Royal Rumble’ — Biggest Week In WWE History?
Rumors always fly around in the world of professional wrestling, but there are a lot happening right now. Actually, there are so many things ...

Satellite pictures suggest oldest Christian monastery in Iraq razed to ground
CNN Satellite pictures suggest oldest Christian monastery in Iraq razed to ground CNN (CNN) A 1,400 year-old Christian monastery the oldest ...

Resources last updated: 1/21/2016 7:58:33 AM