Here is the situation (in VisualC++6 environment):
1. some number is enterd into a CEdit window by user
2. the application has to obtain that number and do some calculations
with it (just like in Windows Calculator), therefore the result must
be
a numeric value(double, float, etc.), not a CString object like it
normally happens with CEdit.
What is better:
to convert CString to number
or
to find a way to get number strait from CEdit?
Some help, please! :cry:
Ajay Kalra - 27 Nov 2004 19:31 GMT
What is really the difference here? You can only get data from CEdit in the
form of text. Only then you can convert it to whatever you want. If it helps
you get it from CString, go for it; if not, do some other way. I suspect
converting from CString will be fine.
-----------
Ajay Kalra
ajaykalra@yahoo.com
> Here is the situation (in VisualC++6 environment):
>
[quoted text clipped - 19 lines]
> www.GroupSrv.com
> *-----------------------*
Rodrigo Aceves - 30 Nov 2004 16:47 GMT
When you use the ClassWizard to add a new variable for the CEdit control,
there is an option where you can specify the type. It can be int, float,
double, CString, or any other you like (you may have a class that inherits
from CString or something).
You can have the variable for the CEdit control as a float, but then you
don't have much control in the way it is presented. If you want to format
the resulting number as you like, use a CString variable and the Format
method. If you don't care use it as a float (or into or double).
For reading the value the user inputs, you can do the same. Have it as a
float and so you don't need to do any type checking (it is done
automatically by VC++), or get it as a CString and convert the number using
atoi, atol or atof (integer, long or double).
Regards
> Here is the situation (in VisualC++6 environment):
>
[quoted text clipped - 19 lines]
> www.GroupSrv.com
> *-----------------------*