Click here to Skip to main content
16,016,178 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMFC Vs. Application, whats the difference? Pin
PocketBlast15-Feb-03 18:24
PocketBlast15-Feb-03 18:24 
AnswerRe: MFC Vs. Application, whats the difference? Pin
Brad Jennings15-Feb-03 19:55
Brad Jennings15-Feb-03 19:55 
GeneralRe: MFC Vs. Application, whats the difference? Pin
PocketBlast15-Feb-03 20:22
PocketBlast15-Feb-03 20:22 
GeneralRe: MFC Vs. Application, whats the difference? Pin
Brad Jennings15-Feb-03 21:18
Brad Jennings15-Feb-03 21:18 
GeneralCan't I use CAtlMap in a MFC project Pin
Kerry Chou15-Feb-03 18:09
Kerry Chou15-Feb-03 18:09 
Generalmethods to manipulate SYSTEMTIME Pin
king_of_the_world15-Feb-03 15:53
king_of_the_world15-Feb-03 15:53 
GeneralRe: methods to manipulate SYSTEMTIME Pin
Neville Franks15-Feb-03 20:29
Neville Franks15-Feb-03 20:29 
GeneralConvert Long to String, how? (Newbie) Pin
PocketBlast15-Feb-03 15:24
PocketBlast15-Feb-03 15:24 
Okay, Ive got the other part of my problem fixed, and it appears to be working... That is, fetching text values from Edit Boxes and converting them to Long, then adding them for the sum.

Now, I want to convert the sum variable back to text so it can be used in a message box.

Heres what I have, code snippit:

===========================================================

// Fetch the text from Edit Boxes 1 and 2, and assign them
// to variables Number1 and 2.
GetDlgItemText(IDC_EDIT1, Number1);
GetDlgItemText(IDC_EDIT2, Number2);

// Initilize Long variables for number 1 and 2,
// and the resulting sum, Answer.
long N1;
long N2;
long Ans;

// Convert the text Number1 to Long N1,
// and 2 respectivly
N1 = wcstol(Number1, NULL, 10);
N2 = wcstol(Number2, NULL, 10);

// Add for the sum
Ans = N1 + N2;


// * Error compiling here.. *
// Objective: convert the Long Ans to the
// string AnsSum for printing in message box, etc..
CString AnsSum = atol( Ans );


// Build the text string TmpTxt to be used in message box
CString TmpTxt = "The numbers are " + Number1 + " and " + Number2 + " and the sum is " + _T(AnsSum);

// Finally, display the message box
MessageBox(TmpTxt, _T("Your answer"), MB_ICONINFORMATION | MB_OK);


===========================================================

Im getting these errors:
error C2664: 'atol' : cannot convert parameter 1 from 'long' to 'const char *'
error C2065: 'LAnsSum' : undeclared identifier
error C2666: '+' : 5 overloads have similar conversions



As you may recall from my previou post, this is a super newbie project Im working on, fetch two text vals from two edit boxes, convert them to Long, add them for the sum, convert the Long sum to Text and display the answer in a message box.

This project is introducing me to several various 'C++' structures and getting me used to the IDE. I am making progress, but I feel like a total idiot because I cant develop this simple app without having to ask questions. Cry | :((

I come from years of app dev with VB, so this is quite a change for me.

If you reply, please address me as the idiot I am so I understand what I am doing wrong, and what I need to do, and if you feel fancy, the why... Blush | :O

Thanks,
Andrew



New to VC++ programming, working hard to learn. Smile | :)
GeneralRe: Convert Long to String, how? (Newbie) Pin
PJ Arends15-Feb-03 16:15
professionalPJ Arends15-Feb-03 16:15 
GeneralRe: Convert Long to String, how? (Newbie) Pin
Michael Dunn15-Feb-03 16:18
sitebuilderMichael Dunn15-Feb-03 16:18 
GeneralRe: Convert Long to String, how? (Newbie) Pin
PocketBlast15-Feb-03 17:02
PocketBlast15-Feb-03 17:02 
GeneralRe: Convert Long to String, how? (Newbie) Pin
PJ Arends15-Feb-03 16:35
professionalPJ Arends15-Feb-03 16:35 
GeneralRe: Convert Long to String, how? (Newbie) Pin
PocketBlast15-Feb-03 17:09
PocketBlast15-Feb-03 17:09 
GeneralRe: Convert Long to String, how? (Newbie) Pin
Brad Jennings15-Feb-03 19:28
Brad Jennings15-Feb-03 19:28 
GeneralRe: Convert Long to String, how? (Newbie) Pin
PocketBlast15-Feb-03 20:18
PocketBlast15-Feb-03 20:18 
GeneralRe: Convert Long to String, how? (Newbie) Pin
Brad Jennings15-Feb-03 20:54
Brad Jennings15-Feb-03 20:54 
GeneralRe: Convert Long to String, how? (Newbie) Pin
Ted Ferenc15-Feb-03 22:08
Ted Ferenc15-Feb-03 22:08 
GeneralRe: Convert Long to String, how? (Newbie) Pin
PocketBlast16-Feb-03 7:50
PocketBlast16-Feb-03 7:50 
GeneralRe: Convert Long to String, how? (Newbie) Pin
Brad Jennings16-Feb-03 11:08
Brad Jennings16-Feb-03 11:08 
GeneralRe: Convert Long to String, how? (Newbie) Pin
Ted Ferenc16-Feb-03 21:33
Ted Ferenc16-Feb-03 21:33 
Generalccombo + fonts Pin
DuFF15-Feb-03 15:09
DuFF15-Feb-03 15:09 
GeneralCWinThread Pin
king_of_the_world15-Feb-03 15:05
king_of_the_world15-Feb-03 15:05 
GeneralRe: CWinThread Pin
valikac15-Feb-03 15:15
valikac15-Feb-03 15:15 
GeneralRe: CWinThread Pin
king_of_the_world15-Feb-03 15:17
king_of_the_world15-Feb-03 15:17 
GeneralRe: CWinThread Pin
Gary R. Wheeler16-Feb-03 4:33
Gary R. Wheeler16-Feb-03 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.