GetDlgItemText getting a float
-
Ok, so im running MS Visual C++ 6.0, programming a C++ MFC program. Im my dialog i have a edit box (locked to numbers) were the user will type in a float (a price) So then i have to use GetDlgItemText go get the float into a CString (cant use getdlgitemint as it looses the decimals) but now i then need to convert the cstring (containing someting like 29.88) into a normal float, like this: Main->Price=cstringprice; ive tried loads of things, like atof.. but all of them make errors when trying to use the variable it set so got any better ideas of getting a float from the dialog into a float? or converting what GetDlgItemText brings into a float? thanks!
/Johannes
-
Ok, so im running MS Visual C++ 6.0, programming a C++ MFC program. Im my dialog i have a edit box (locked to numbers) were the user will type in a float (a price) So then i have to use GetDlgItemText go get the float into a CString (cant use getdlgitemint as it looses the decimals) but now i then need to convert the cstring (containing someting like 29.88) into a normal float, like this: Main->Price=cstringprice; ive tried loads of things, like atof.. but all of them make errors when trying to use the variable it set so got any better ideas of getting a float from the dialog into a float? or converting what GetDlgItemText brings into a float? thanks!
/Johannes
atof() should work just fine. Perhaps you could show the code for your converting and we may be able to point out the error.
-
Ok, so im running MS Visual C++ 6.0, programming a C++ MFC program. Im my dialog i have a edit box (locked to numbers) were the user will type in a float (a price) So then i have to use GetDlgItemText go get the float into a CString (cant use getdlgitemint as it looses the decimals) but now i then need to convert the cstring (containing someting like 29.88) into a normal float, like this: Main->Price=cstringprice; ive tried loads of things, like atof.. but all of them make errors when trying to use the variable it set so got any better ideas of getting a float from the dialog into a float? or converting what GetDlgItemText brings into a float? thanks!
/Johannes
-
Ok, so im running MS Visual C++ 6.0, programming a C++ MFC program. Im my dialog i have a edit box (locked to numbers) were the user will type in a float (a price) So then i have to use GetDlgItemText go get the float into a CString (cant use getdlgitemint as it looses the decimals) but now i then need to convert the cstring (containing someting like 29.88) into a normal float, like this: Main->Price=cstringprice; ive tried loads of things, like atof.. but all of them make errors when trying to use the variable it set so got any better ideas of getting a float from the dialog into a float? or converting what GetDlgItemText brings into a float? thanks!
/Johannes
You can use of
CString str;
str.Format("%lf",28.29);But what errors when used of atof?
WhiteSky
-
Ok, so im running MS Visual C++ 6.0, programming a C++ MFC program. Im my dialog i have a edit box (locked to numbers) were the user will type in a float (a price) So then i have to use GetDlgItemText go get the float into a CString (cant use getdlgitemint as it looses the decimals) but now i then need to convert the cstring (containing someting like 29.88) into a normal float, like this: Main->Price=cstringprice; ive tried loads of things, like atof.. but all of them make errors when trying to use the variable it set so got any better ideas of getting a float from the dialog into a float? or converting what GetDlgItemText brings into a float? thanks!
/Johannes
try _ttod
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you