Format number

sigster

Member
Joined
Feb 7, 2010
Messages
12
Programming Experience
Beginner
Hi

Is anyone here who can help me with this thanks

How can I format this number in vb.net



from Database = 1482000
Need format like this = 148.200.000

from Database = 28400,0
Need format like this = 28.400.000

from Database = 34500
Need format like this = 34.500.000

from Database = 33750,0
Need format like this = 33.750.000

from Database = 9500
Need format like this = 9.500.000


Is did try this and I did get 1.482.000 but I need to have 148.200.000

VB.NET:
myDecimal = System.Convert.ToDecimal(reader.GetDouble(11))
Dim Out_val = myDecimal.ToString("C")
 
Your question makes little sense. Examples are great but you need to actually explain the rules. Code is an implementation of logic so we need to know what that logic is, so YOU need to know what that logic is. Do you? In the last four cases, it appears that you are multiplying by 1000 and including thousand/group separators in the output but in the first case it appears that you're only multiplying by 100. Please provide a FULL and CLEAR explanation of the problem.
 
Also, what is your local culture? You're apparently somewhere that uses "," as a decimal separator and "." as a thousand/group separator, which is fine, but the "C" format specifier is for currency so I would expect that you include the local currency symbol too, but you seem to be indicating that it doesn't. Basically, you should use "N" or "F". One of them includes thousand/group separators and one doesn't and I can never remember which is which, but you can test that easily enough. You can also specify the number of digits after the decimal separator, so probably "N0" or "F0". If you need to multiply the number by 100 or 1000 or whatever first then do so. You don't need us to tell you how to perform basic arithmetic.
 
Back
Top