?
Solved

Easy Format Question

Posted on 2004-03-21
4
Medium Priority
?
186 Views
Last Modified: 2013-11-20
Hi

Using CString::Format how do I format 1234 to be 1,234
0
Comment
Question by:Dj_Fx8
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
info_expert earned 500 total points
ID: 10644630
There is no specific automatic method for this purpose in CString, but u can use your brain.
the len method of CString  returns the length of CString. you will do:

int groups=s1.len() /3;
CString s2;

now as you know the length of string

for(int c=len; c>3; c-=3)
{
//take the substring from s1 and put in s2 and then put the comma in s2.
//the length of s2 will be = s1.len() + groups;
}

Got?

Regards
0
 
LVL 5

Expert Comment

by:info_expert
ID: 10644652
One thing i forgot to tell that you can use the same string and use the 'insert' function to insert the commas in string but you will have to determine the number of groups of strings to be made in source string.
0
 

Author Comment

by:Dj_Fx8
ID: 10644717
Hi

>>>u can use your brain

I was hoping I wouldn't have to do that :-) I have no prob working it out, but just was wondering if there was an easier way.

Many Thanks
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 10647737
Have a look at GetNumberFormat in help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question