Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert a numeric value to a CString. 1

Status
Not open for further replies.

jrjones666

Programmer
Oct 5, 2001
5
US
Hello,

I am fairly new at VC programming. I have a numeric value that I want to add to a listbox. The variable behind the listbox is a CString. I need to know how to convert my numeric value to a CString.

Thanks for any help.

John
 
--more exact to what Ady said:
int n=10;
double d=12;
CString myString;
myString.Format("Integer=%d, Double=%.2lf", n,d);

- a second method would be:
char buffer[20];
_itoa(n,buffer,10);
CString myString(buffer);

//for float/double values consider using _fcvt and _ecvt s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
That was extremely helpful, IonelBurtan. I had tried using the format method before but could not get it to work until I got the format from you.

Thank you very much.

~J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top