How to control data from edit box
-
I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.
Thanks Terry
-
I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.
Thanks Terry
try to use a CString var in which u read the text typed. and then use the atoi() funct/. such : CString TXT; int Nbr; m_EditContr.GetWindowText(TXT); if (TXT.IsEmpty()!=0) Nbr.atoi(TXT); But when the user type such thing (ASD45O) it may not work. !!!
"The Ultimate Limit Is Only Your Imagination."
-
I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.
Thanks Terry
Add a control variable to your edit box, may it be
c_Edit
. You can use this variable to get the text entered in your edit box by callingc_Edit.GetWindowText()
. This function will always return anLPTSTR
. You can use conversion functions like_ttoi()
just in case you need numbers. Here are some tutorials which may help you: CEdit Tutorial 1[^] CEdit tutorial 2[^] CEdit tutorial 3[^] I also suggest that you read a good book on MFC (well, if you are using MFC) and on Win32.Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
try to use a CString var in which u read the text typed. and then use the atoi() funct/. such : CString TXT; int Nbr; m_EditContr.GetWindowText(TXT); if (TXT.IsEmpty()!=0) Nbr.atoi(TXT); But when the user type such thing (ASD45O) it may not work. !!!
"The Ultimate Limit Is Only Your Imagination."
-
Blood_HaZaRd wrote:
Nbr.atoi(TXT);
or
Nbr = atoi(TXT);
Typo? ;) Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
LOL, yup it was a typo mistake :p
"The Ultimate Limit Is Only Your Imagination."
-
I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.
Thanks Terry
Trupti Mehta wrote:
How can I get data and convert it back to int, float or date respectively
You can use of GetWindowText and then see CString::Format.
-
LOL, yup it was a typo mistake :p
"The Ultimate Limit Is Only Your Imagination."
Then edit your answer... or are you lazy? :P
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.