"He averted a major costly disaster...". I've worked with roughly a dozen coders, graphics people and so forth in my past 10 years or so of business coaching and consulting. I've actually become pretty good at finding the right fit.

–Dan Nichols, America's Business Launch Expert(Michigan, USA)

Great job, love your work, exceeded my expecations once again.

–Mr. Robert Guinta (Sydney, Australia)

Another excellent job! Will keep working with the Raven team.

–Daniel Garcia (Miami, USA)

Raven developers did a great job on website optimisation and fixes for IE6 and generated a sitemap for very large website. I recommend them very much.

–Srdjan Bajic (Beograd, Serbia)

Excellent job again! A++++ coder

–Daniel Garcia (Miami, USA)

Great work, I am really impressed with the quality of work, your guidance and the professionalism that you display. Thankyou

–Mr. Robert Guinta (Sydney, Australia)

I had a really great experience with these coders. They are extremely detail oriented and worked very hard on a tedious project until it was completed exactly as needed. Highly recommended.

–Mr. Somlor (Washington, USA)

Very professional work, great standard.

–Mr. Robert Guinta (Sydney, Australia)

Very polite and easy people to work with :)

–Mr. Stephen (Calgary, Alberta)

High quality work, on schedule, very reliable, and were able to revise and revise until it was perfect.

–The Piano Man (San Diego, California)

Very good at listening and understanding.

–Lexxes (Bollnas, Halsingland)

Excellent work...very prompt service & most important very co-operative even with minutest changes...would work with this coders in future.

–Nitish Kanade (Newyork, USA)

Work was PERFECT!!!! Thank you!

–Robert Francia (Toronto, Canada)

My only regret in using these coders is they keep getting more popular. They are excellent - top shelf. Way above the curve on knowing what the client needs even over what they want. It's not like working with a vendor. It's more like a teammate relationship.

–DJ Dan Nichols (Royal Oak Michigan, USA)

Coder's work was very good and they followed everything we asked. Design was just want I wanted. Whole website was in div's and xHTML Strict Valid. They were very responsible on deadlines and often made comments and good time estimates. I recommend these coders very much.

–Srdjan Bajic (Beograd, Serbia)

I was surprised with the quality of work. I enjoyed working and communicating. A Gem! Thank you!

–Mr. Issac M (Brooklyn, USA)

I have found many great coders but sometimes you don't know that great can be topped. These coders are exceptionally great. They really branded me nicely, handled the request and did so thought-"fully".

–DJ Dan Nichols (Royal Oak Michigan, USA)

These coders completed all work to a high standard and worked to ensure that good communication channels where kept open throughout the project. Would and will be using again in the future.

–Chris Allen (Cambridge, England)


On a local project I required AMOUNTS to be converted in to words, The project was based on Embarcadero (Formerly known as Borland) Flagship Product Embarcadero Delphi now also known as RAD Application Suite. I searched all over the net for a code snippet but much to my dismay I found nothing! So, it was up to me to create my own little PASCAL snippet to convert AMOUNTS in to WORDS. So, All you have to do is copy & paste this snippet in to your PASCAL unit or download the attached CurrToWords.pas file attached herewith:

{
+------------------------------------------------------------------------------------------+
COMPANY:Raven Developers 2008
+------------------------------------------------------------------------------------------+
FILE INFO: Currency to words converter PASCAL UNIT, for INR currency ONLY!
+------------------------------------------------------------------------------------------+
Portions created by Anirudh K. Mahant are Copyright of Raven Developers (C) 2008.
+------------------------------------------------------------------------------------------+
COPYRIGHT NOTICE:
The contents of this file are protected and copyrighted and are subject to
the original developer(s) of this file;Unauthorised use of this file is strictly prohibited.   

URL:
http://www.ravendevelopers.com
+------------------------------------------------------------------------------------------+
}

unit CurrToWords;

interface

uses
  Classes,
  Controls,
  Dialogs,
  Forms,
  StrUtils,
  SysUtils,
  Variants,
  Windows;

function CurrencyToWord(MyNumber: variant): string;
function ConvertHundreds(MyNumber: variant): string;
function ConvertTens(MyTens: variant): string;
function ConvertDigit(MyDigit: variant): string;

implementation

function CurrencyToWord(MyNumber: variant): string;
var
  Temp:  string;
  Rupees, Paisa, Hundreds, Words: string;
  DecimalPlace, iCount: integer;
  Place: array[0..9] of string;
begin
  Place[0] := ' Thousand ';
  Place[2] := ' Lakh ';
  Place[4] := ' Crore ';
  Place[6] := ' Arab ';
  Place[8] := ' Kharab ';

  //Convert MyNumber to a string, trimming extra spaces.
  MyNumber := Trim(VarToStr(MyNumber));

  //Find decimal place.
  DecimalPlace := AnsiPos('.', MyNumber);

  //If we find decimal place...
  if DecimalPlace > 0 then
  begin
    //Convert Paisa
    Temp  := LeftStr(MidStr(MyNumber, DecimalPlace + 1, 2) + '00', 2);
    Paisa := ' and ' + ConvertTens(Temp) + ' Paisa';
    //Strip off paisa from remainder to convert.
    MyNumber := Trim(LeftStr(MyNumber, DecimalPlace - 1));
  end;

  //Convert last 3 digits of MyNumber to ruppees in word.
  Hundreds := ConvertHundreds(RightStr(MyNumber, 3));
  //Strip off last three digits
  MyNumber := LeftStr(MyNumber, StrLen(PChar(VarToStr(MyNumber))) - 3);

  iCount := 0;
  while MyNumber <> '' do
  begin
    //Strip last two digits
    Temp := RightStr(MyNumber, 2);
    if StrLen(PChar(VarToStr(MyNumber))) = 1 then
    begin
      Words := ConvertDigit(Temp) + Place[iCount] + Words;
      MyNumber := LeftStr(MyNumber, StrLen(PChar(VarToStr(MyNumber))) - 1);
    end
    else
    begin
      Words := ConvertTens(Temp) + Place[iCount] + Words;
      MyNumber := LeftStr(MyNumber, StrLen(PChar(VarToStr(MyNumber))) - 2);
    end;
    Inc(iCount, 2);
  end;
  Result := Words + Hundreds + Paisa;
end;

//Conversion for hundreds
function ConvertHundreds(MyNumber: variant): string;
var
  inResult: string;
begin
  //Exit if there is nothing to convert.
  if StrToInt(VarToStr(MyNumber)) = 0 then
    Exit;
  //Append leading zeros to number.
  MyNumber := RightStr('000' + MyNumber, 3);
  //Do we have a hundreds place digit to convert?
  if LeftStr(MyNumber, 1) <> '0' then
    inResult := ConvertDigit(LeftStr(MyNumber, 1)) + ' Hundred ';
  //Do we have a tens place digit to convert?
  if MidStr(MyNumber, 2, 1) <> '0' then
    inResult := inResult + ConvertTens(MidStr(MyNumber, 2, 2))
  else
    //If not, then convert the ones place digit.
    inResult := inResult + ConvertDigit(MidStr(MyNumber, 3, 2));
  Result := Trim(inResult);
end;

//Conversion for tens
function ConvertTens(MyTens: variant): string;
var
  inResult: string;
begin
  //Is value between 10 and 19?
  if StrToInt(VarToStr(LeftStr(VarToStr(MyTens), 1))) = 1 then
  begin
    case StrToInt(VarToStr(MyTens)) of
      10: inResult := 'Ten';
      11: inResult := 'Eleven';
      12: inResult := 'Twelve';
      13: inResult := 'Thirteen';
      14: inResult := 'Fourteen';
      15: inResult := 'Fifteen';
      16: inResult := 'Sixteen';
      17: inResult := 'Seventeen';
      18: inResult := 'Eighteen';
      19: inResult := 'Nineteen';
      else
    end;
  end
  else
  begin
    //otherwise it's between 20 and 99.
    case StrToInt(VarToStr(LeftStr(VarToStr(MyTens), 1))) of
      2: inResult := 'Twenty ';
      3: inResult := 'Thirty ';
      4: inResult := 'Forty ';
      5: inResult := 'Fifty ';
      6: inResult := 'Sixty ';
      7: inResult := 'Seventy ';
      8: inResult := 'Eighty ';
      9: inResult := 'Ninety ';
      else
    end;
    //Convert ones place digit.
    inResult := inResult + ConvertDigit(RightStr(MyTens, 1));
  end;
  Result := inResult;
end;

function ConvertDigit(MyDigit: variant): string;
var
  inResult: string;
begin
  case StrToInt(VarToStr(MyDigit)) of
    1: inResult := 'One';
    2: inResult := 'Two';
    3: inResult := 'Three';
    4: inResult := 'Four';
    5: inResult := 'Five';
    6: inResult := 'Six';
    7: inResult := 'Seven';
    8: inResult := 'Eight';
    9: inResult := 'Nine';
    else
      inResult := '';
  end;
  Result := inResult;
end;

end.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <div> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p> <h1> <h2> <h3> <h4> <h5> <h6> <acronym> <blockquote> <b> <i> <font> <table> <object> <embed>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

1 + 6 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.