Adding comma to a number

Hi ,

I wanted to add comma to a number

Could you please guide me here…

Example 7000 output 7,000

Thanks

Hey @Rahul_S1

Check this out

1 Like

@Rahul_S1

you can try with

inputstr.Insert(1,“,”)

output= “7,000”

1 Like

@nikhil.girish thanks

1 Like

Thanks @Shiva_Nikhil

1 Like

maybe you are looking for this also
grafik

1 Like

Hi @Rahul_S1

String.Format(“{0:N0}”, 7000)

1 Like

I assume it’s being stored in a string variable, and you want to output it as a string with the thousands separator as comma. (If it’s an integer or double variable, there is no such thing as a thousands separator)

To take a string and output it with thousands separator as comma:

myStr = 7000
CDBl(myStr).ToString("N0",System.Globalization.CultureInfo.InvariantCulture)
image

Don’t use string manipulation (ie insert) because it won’t work if the number is hundreds of thousands, millions, etc. Do proper conversion to a number datatype, then proper formatting expression.

Also, if you want decimal places you can change the number, ie N1 N2 N3 etc.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.