web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

X++ str2Num("4 600") returns "4" instead of "4600,00"

(0) ShareShare
ReportReport
Posted on by 105

How to convert a string that contains a space (ex: 4 600)  to a real?

The str2Num function would return "4" instead of "4600,00".

 

Regards,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,876 Most Valuable Professional on at

    You have many options. If the problem is just with spaces, you can simply remove them by strRem(). You could do it more general by actually keeping valid characters (strKeep()), but you would still have to be careful about things like the decimal mark.

    In more complex scenarios, I would consider using System.Single::Parse().

    You may be also interested in checking whether a number is actually valid - str2NumOk() can be used for that.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans