Want in MFC equivalent of Double.TryParse

I  have to convert  following  C#  code as  it is MFC. In  following  code it is  used Double.TryParse,I  am  unable to  find equivalent  for  same  in MFC,Please  help  for  same
public bool IsValidCutOffFormula(String StrExpression )
        {
            try
            {
                Int16 iFirstOperator=0;
                Int16 iSecondOperator = -1;
                String StrOperators = "+-/*";
                String StrOprand="";
                double dblResults;
                for (Int16 iCount = 0; iCount < StrExpression.Length ; iCount++)
                {
                    
                        if (StrOperators.Contains(StrExpression.Substring(iCount, 1)))
                        {
                            iFirstOperator = iSecondOperator;
                            iSecondOperator = iCount;
                            StrOprand = StrExpression.Substring(iFirstOperator + 1, iSecondOperator - iFirstOperator-1);
                            if (StrOprand == String.Empty)
                            {
                                return false;
                            }
                            else
                            {
                                
                                if (Double.TryParse(StrOprand, out dblResults) == false)
                                {
                                    if (StrOprand == "NC" || StrOprand == "PC" || StrOprand == "COC")
                                    {
                                        //return true;
                                    }
                                    else
                                        return false;
                                }

                            }

                        }                    
                }
                if (iFirstOperator == 0 || iSecondOperator == -1) // No operator found 
                {
                    if (ExpressionValidate(StrExpression) == false) //NC Or PC or Constant value used as cut-OFf
                        return false;
                }
                else if (iSecondOperator == StrExpression.Length - 1) // Expression shuold not be terminated with operator
                {
                    return false;
                }
                else
                {
                    if (iSecondOperator> 0)
	                    {
                            //StrExpression = StrExpression.Substring(iSecondOperator+1);
                            if (ExpressionValidate(StrExpression.Substring(iSecondOperator + 1)) == false) //NC Or PC or Constant value used as cut-OFf
                            return false;
	                    }

                    
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        //Checking expression in cut off formula for NC,PC,COC added @20 mar 2014.
        public bool ExpressionValidate(String StrExpression)
        {
            double dblResults;
            if (StrExpression == "NC" || StrExpression == "PC" || StrExpression == "COC" || Double.TryParse(StrExpression, out dblResults) == true) // NC Or PC or Constant value used as cut-OFf
            {
                return true;
            }
            else
                return false;
        }

Open in new window

ADITYA RAOSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
There isn't any direct MFC equivalent of the TryParse.  You will have to write your own.
The following will help you get started:
http://msdn.microsoft.com/en-us/library/5948ysye.aspx
which is about the _atodbl function (string to double).  There is also an atof (and related functions) that performs a similar task but handles errors in a different way.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.