Help With Code:Arabic Number to Text

A

Abdul

Hello,

Can some one help me to convert the following code to VBA
for posting purpose I have changed arabic text to english numbers,
since binary post is not allowed
using System;
/// <summary>
/// it's a sealed class to convert int number (0-9999)
/// to Arabic string
/// </summary>
public sealed class NumToArabicString
{
/// <summary>
/// take int as string value and return Arabic string
/// </summary>
public static string NtoS(string InputString)
{
if ((InputString.Length>0)&&(InputString.Length<=4))
{
string F1, F2, F3, F4;
int Number,Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
Number=System.Convert.ToInt16(InputString);
if (Number >= 0)
{
Num4 = (int)Number / 1000;
Num5 = Number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = " for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " Ùˆ " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100 ";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "for 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "FOR 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 ==0))
{
F1 = F4;
}
}
return F1;
}
return "";

}
/// <summary>
/// take int and return Arabic string
/// </summary>
public static string NtoS(Int16 number)
{
if((number>=0)&&(number<=9999))
{
string F1, F2, F3, F4;
int Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
if (number >= 0)
{
Num4 = (int)number / 1000;
Num5 = number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = "for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " for and " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "fir 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "for 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 ==0))
{
F1 = F4;
}
}
return F1;
}
return "";
}

[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
}
}
 
N

NickHK

You would probably find it easier to start with one of the many English
Number-ToText routines in VB/VBA.
Maybe:
http://www.ozgrid.com/VBA/ValueToWords.htm

NickHK

Hello,

Can some one help me to convert the following code to VBA
for posting purpose I have changed arabic text to english numbers,
since binary post is not allowed
using System;
/// <summary>
/// it's a sealed class to convert int number (0-9999)
/// to Arabic string
/// </summary>
public sealed class NumToArabicString
{
/// <summary>
/// take int as string value and return Arabic string
/// </summary>
public static string NtoS(string InputString)
{
if ((InputString.Length>0)&&(InputString.Length<=4))
{
string F1, F2, F3, F4;
int Number,Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
Number=System.Convert.ToInt16(InputString);
if (Number >= 0)
{
Num4 = (int)Number / 1000;
Num5 = Number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = " for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " ? " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100 ";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "for 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "FOR 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 == 0))
{
F1 = F4;
}
}
return F1;
}
return "";

}
/// <summary>
/// take int and return Arabic string
/// </summary>
public static string NtoS(Int16 number)
{
if((number>=0)&&(number<=9999))
{
string F1, F2, F3, F4;
int Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
if (number >= 0)
{
Num4 = (int)number / 1000;
Num5 = number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = "for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " for and " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "fir 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "for 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 == 0))
{
F1 = F4;
}
}
return F1;
}
return "";
}

[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
}
}
 
A

Abdul

Thanks NickHK

In Arabic it is not the same way as english.

For eg One hundered is "Mia" and two Hundred is "Miathan" and from
three hundred onwards it is equal to "three Mia" and "Four Mia" etc.

It is the same for thousand and so on.. also for eleven and tweleve
it is not in the normal order. and the "and" get repeated with every
word also.

thanks again



You would probably find it easier to start with one of the many English
Number-ToText routines in VB/VBA.
Maybe:
http://www.ozgrid.com/VBA/ValueToWords.htm

NickHK

Hello,

Can some one help me to convert the following code to VBA
for posting purpose I have changed arabic text to english numbers,
since binary post is not allowed
using System;
/// <summary>
/// it's a sealed class to convert int number (0-9999)
/// to Arabic string
/// </summary>
public sealed class NumToArabicString
{
/// <summary>
/// take int as string value and return Arabic string
/// </summary>
public static string NtoS(string InputString)
{
if ((InputString.Length>0)&&(InputString.Length<=4))
{
string F1, F2, F3, F4;
int Number,Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
Number=System.Convert.ToInt16(InputString);
if (Number >= 0)
{
Num4 = (int)Number / 1000;
Num5 = Number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = " for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " ? " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100 ";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "for 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "FOR 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 == 0))
{
F1 = F4;
}
}
return F1;
}
return "";

}
/// <summary>
/// take int and return Arabic string
/// </summary>
public static string NtoS(Int16 number)
{
if((number>=0)&&(number<=9999))
{
string F1, F2, F3, F4;
int Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
if (number >= 0)
{
Num4 = (int)number / 1000;
Num5 = number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = "for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " for and " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "fir 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "for 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 == 0))
{
F1 = F4;
}
}
return F1;
}
return "";
}

[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
}
}
 
N

NickHK

Abdul,
I can't help much, not knowing the structure of Arabic numerals/text.
You will need to have more complex Select Case statement to decide the
correct word(s) for the number, the same basic logic still applies, I
imagine.

Maybe this ?
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4218&lngWId=10

NickHK

Abdul said:
Thanks NickHK

In Arabic it is not the same way as english.

For eg One hundered is "Mia" and two Hundred is "Miathan" and from
three hundred onwards it is equal to "three Mia" and "Four Mia" etc.

It is the same for thousand and so on.. also for eleven and tweleve
it is not in the normal order. and the "and" get repeated with every
word also.

thanks again



You would probably find it easier to start with one of the many English
Number-ToText routines in VB/VBA.
Maybe:
http://www.ozgrid.com/VBA/ValueToWords.htm

NickHK

Hello,

Can some one help me to convert the following code to VBA
for posting purpose I have changed arabic text to english numbers,
since binary post is not allowed
using System;
/// <summary>
/// it's a sealed class to convert int number (0-9999)
/// to Arabic string
/// </summary>
public sealed class NumToArabicString
{
/// <summary>
/// take int as string value and return Arabic string
/// </summary>
public static string NtoS(string InputString)
{
if ((InputString.Length>0)&&(InputString.Length<=4))
{
string F1, F2, F3, F4;
int Number,Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
Number=System.Convert.ToInt16(InputString);
if (Number >= 0)
{
Num4 = (int)Number / 1000;
Num5 = Number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = " for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " ? " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100 ";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "for 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "FOR 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 == 0))
{
F1 = F4;
}
}
return F1;
}
return "";

}
/// <summary>
/// take int and return Arabic string
/// </summary>
public static string NtoS(Int16 number)
{
if((number>=0)&&(number<=9999))
{
string F1, F2, F3, F4;
int Num0, Num1, Num2, Num3,Num4,Num5;
F4 = "";
F3 = "";
F2 = "";
F1 = "";
if (number >= 0)
{
Num4 = (int)number / 1000;
Num5 = number % 1000;
Num1 = (int)Num5 / 100;
Num0 = Num5%100;
Num2 = (int)Num0 / 10;
Num3 = Num0%10;

switch(Num3)
{
case 1 : F1 = "for 1";
break;
case 2 : F1 = "for 2 ";
break;
case 3 : F1 = "for 3";
break;
case 4 : F1 = "for 4";
break;
case 5 : F1 = "for 5";
break;
case 6 : F1 = "for 6";
break;
case 7 : F1 = "for 7";
break;
case 8 : F1 = "for 8";
break;
case 9 : F1 = "for 9";
break;
default: F1 = "for 0";
break;
}
switch(Num2)
{
case 1 : F2 = "for 10";
break;
case 2 : F2 = "for 20 ";
break;
case 3 : F2 = "for 30";
break;
case 4 : F2 = "for 40";
break;
case 5 : F2 = "for 50";
break;
case 6 : F2 = "for 60";
break;
case 7 : F2 = "for 70";
break;
case 8 : F2 = "for 80";
break;
case 9 : F2 = "for 90";
break;
default: F2 = "for 0";
break;
}
if (Num2 != 0)
{
if ((Num2 == 1) && (Num3 != 0))
{
F1 = F1 + F2;
}
else
{
if ((Num3 !=0)&&( Num2 != 0))
{
F1 = F1 + " for and " + F2;
}
else if(Num2!=0)
{
F1 = F2;
}
}
}
switch(Num1)
{
case 1 : F3 = "for 100";
break;
case 2 : F3 = "for 200 ";
break;
case 3 : F3 = "for 300";
break;
case 4 : F3 = "fir 400";
break;
case 5 : F3 = "for 500";
break;
case 6 : F3 = "for 600";
break;
case 7 : F3 = "for 700";
break;
case 8 : F3 = "for 800";
break;
case 9 : F3 = "for 900";
break;
default: F3 = "for 0";
break;
}

if ((Num1 > 0)&&( F1 !="for 0"))
{
F1 = F3 + " for and " + F1;
}
if((Num1 != 0)&&(Num2 == 0)&&(Num3 == 0))
{
F1 = F3;
}

switch (Num4)
{
case 1:F4 = "for 1000";
break;
case 2:F4 = "for 2000";
break;
case 3:F4 = "for 3000";
break;
case 4:F4 = "for 4000";
break;
case 5:F4 = "for 5000";
break;
case 6:F4 = "for 6000";
break;
case 7:F4 = "for 7000";
break;
case 8:F4 = "for 8000";
break;
case 9:F4 = "for 9000";
break;
default:F4 = "for 0";
break;
}
if((Num4 > 0)&&(F1 != "for 0"))
{
F1 = F4 + " for and " + F1;
}
if ((Num4 != 0) &&( Num1 == 0) &&( Num2 == 0)&&( Num3 == 0))
{
F1 = F4;
}
}
return F1;
}
return "";
}

[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top