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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get a Number transfer in text

(0) ShareShare
ReportReport
Posted on by 14

Hi, i need your help

From a erp-interface i get numbers in my field 0,1,2 . but i need text that the user understood the sin of the value. 

can i create a sript or something to do that simple?

Thanx 

Dirk

*This post is locked for comments

I have the same question (0)
  • Vipin J Profile Picture
    1,603 on at

    do you mean

    0 - Zero

    1 - One

    2 - Two

    What is the range of number are we talking about here.

    Do you want this as well

    1523 -

    One thousand five hundred and twenty three only.

    or

    One Five Two Three

  • Suggested answer
    Saad Kabarousse Profile Picture
    734 on at

    Hello,

    You can use this methode it works fine for me:

           public static string NumberToWords(int number)

           {

               if (number == 0)

                   return "zero";

               if (number < 0)

                   return "minus " + NumberToWords(Math.Abs(number));

               string words = "";

               if ((number / 1000000) > 0)

               {

                   words += NumberToWords(number / 1000000) + " million ";

                   number %= 1000000;

               }

               if ((number / 1000) > 0)

               {

                   words += NumberToWords(number / 1000) + " thousand ";

                   number %= 1000;

               }

               if ((number / 100) > 0)

               {

                   words += NumberToWords(number / 100) + " hundred ";

                   number %= 100;

               }

               if (number > 0)

               {

                   if (words != "")

                       words += "and ";

                   var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };

                   var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

                   if (number < 20)

                       words += unitsMap[number];

                   else

                   {

                       words += tensMap[number / 10];

                       if ((number % 10) > 0)

                           words += "-" + unitsMap[number % 10];

                   }

               }

               return words;

           }

    If you find helpful , Please make this response as verified

  • gdas Profile Picture
    50,091 Moderator on at

    You can do this easily using JavaScript . Take a look below reference hope this will helps you.

    https://jsfiddle.net/lesson8/5tt7d3e6/

    https://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript

  • Ramses1973 Profile Picture
    14 on at

    Hi Vipin, the first scenario is right one. Number 0 is String "Zero", number 1 is String "One" and number 2 is String "Two".

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi Ramses1973,

    You can do with below javascript code

    function convertNumberToWords(amount) {
    var words = new Array();
    words[0] = '';
    words[1] = 'One';
    words[2] = 'Two';
    words[3] = 'Three';
    words[4] = 'Four';
    words[5] = 'Five';
    words[6] = 'Six';
    words[7] = 'Seven';
    words[8] = 'Eight';
    words[9] = 'Nine';

    amount = amount.toString();
    var atemp = amount.split(".");
    var number = atemp[0].split(",").join("");
    var n_length = number.length;
    var words_string = "";
    if (n_length <= 9) {
    var n_array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
    var received_n_array = new Array();
    for (var i = 0; i < n_length; i++) {
    received_n_array[i] = words[parseInt(number.substr(i, 1))];
    }
    var wordt;
    wordt = received_n_array.join(' ');
    words_string = wordt;
    }
    return words_string;
    }

    ---HTML---

    <input type="text" name="number" placeholder="Number OR Amount" onkeyup="word.innerHTML=convertNumberToWords(this.value)" />
    <div id="word"></div>

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans