Log in

View Full Version : eVC++ MFC: Getting value from Edit Box?


PPCdev
02-15-2003, 09:16 AM
Im starting slow, trying to learn.

I have a form with two Edit Boxes on it, and a button. I have in the button click event some code which I am trying to assign the value of to a string variable, but I dont even understand the error message.

char va = IDC_EDIT1;
MessageBox(va), _T("You entered"), MB_ICONERROR | MB_OK);

Where as, 'char va', I am trying to assign the variable va as a string, using char, as assign it the contents of IDC_EDIT1.

That seams to be working, but I cant get the message box to dispaly. I can REM out the message box and it compiles and executes. Im not entirly sure I have either line correct.

Sorry to be a pain, Ive read and read post and pages until I no longer understand what Im trying to do. :-(

Thanks for any help..
Andrew

Kati Compton
02-15-2003, 01:28 PM
First of all, you need a CString instead of a char. Second of all, the IDC_whatever is an ID value, not the contents of the edit box.

You need to go into the class wizard, find the edit box, and associate a variable with the edit box in there. I'd tell you how, but unfortunately I don't have time and need to catch a plane.

I'd suggest surfing sites like CodeProject for Visual C++ help, as this isn't an eVC issue, but a VC++ issue.

Good luck!

mel
02-15-2003, 06:21 PM
Try GetDlgItemText...

PPCdev
02-15-2003, 09:11 PM
Kati42, thanks for the site hint, found this that helped a lot!
http://codeproject.com/dialog/dialogapptute.asp

Mel, your helping me get my aim better, my rounds are landing on paper now, Im trying to adjust fire to get them center mass!

This is *not* as easy as VB was, your patience is a big help, thanks for your replies.

Andrew