format a decimal number
-
Hi, How do i specify a decimal number to take only two numbers after the "."? for example: if i have this number in a lable 23.222342114, how do i write my cobe to be displayed only like this 23.22 ?? thanks,
-
Hi, How do i specify a decimal number to take only two numbers after the "."? for example: if i have this number in a lable 23.222342114, how do i write my cobe to be displayed only like this 23.22 ?? thanks,
object.ToString ( "Fn" ) where F is a single alphabetic character called the format specifier, and n can be one or more digits called the precision specifier. Format specifier for decimal D or d so you have to use object.ToString("D2");
-
object.ToString ( "Fn" ) where F is a single alphabetic character called the format specifier, and n can be one or more digits called the precision specifier. Format specifier for decimal D or d so you have to use object.ToString("D2");
I tried what you said but it's not accepting the D2..i'm using a vb.net code so are you sure it's right?
-
I tried what you said but it's not accepting the D2..i'm using a vb.net code so are you sure it's right?
i will just show one example ok decimal i=123.23444; string j=Convert.ToString(Math(i,2)); if print j u will be getting 123.23 Hope this works for u.
-
i will just show one example ok decimal i=123.23444; string j=Convert.ToString(Math(i,2)); if print j u will be getting 123.23 Hope this works for u.
no, it's not working :( i think what you wrote is a c# code not a vb.net when i wrote your code it displayed an error under the word "Math" !
-
no, it's not working :( i think what you wrote is a c# code not a vb.net when i wrote your code it displayed an error under the word "Math" !
-
no, it's not working :( i think what you wrote is a c# code not a vb.net when i wrote your code it displayed an error under the word "Math" !
Iam really sorry for the mistake. actually i missed one small piece of code. Decimal i=Convert.ToDecimal(textBox1.Text); textBox2.Text=Convert.ToString(Math.Round(i,2)); u should give Math.Round(i,2) where i is the decimal no and 2 is the no of decimal places to be rounded to. this will surely work. I am sorry for the previous error ok. Vipin
-
Iam really sorry for the mistake. actually i missed one small piece of code. Decimal i=Convert.ToDecimal(textBox1.Text); textBox2.Text=Convert.ToString(Math.Round(i,2)); u should give Math.Round(i,2) where i is the decimal no and 2 is the no of decimal places to be rounded to. this will surely work. I am sorry for the previous error ok. Vipin
Thanks guys it's working now :D