HACKIS - Hacking Internet Security
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Tuyệt Kỹ Đong Giai Chân Kinh (tuyệt Kỹ cua trai)
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyThu Aug 23, 2012 5:38 am by Admin

» Tuyệt kỹ cua giai
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyThu Aug 23, 2012 5:36 am by Admin

» NETCAT.........
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyMon Aug 13, 2012 6:35 am by Admin

» Bảo mật CSDL bằng phương pháp mã hóa.
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyTue Apr 17, 2012 10:04 pm by Admin

» Hàm mã hóa MD5 bằng JavaScript
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyTue Apr 17, 2012 10:03 pm by Admin

» Giá của món quà
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyFri Apr 13, 2012 6:01 am by Admin

» Sẽ chỉ yêu ai?
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyFri Apr 13, 2012 6:01 am by Admin

» Cách đọc bảng chữ cái!
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyThu Apr 12, 2012 10:37 pm by Admin

» Gắn trojan, keylog, virus vào website, forum
Hàm chuyển đổi từ số thập phân (decimal) sang chữ  EmptyTue Apr 10, 2012 1:14 am by Admin

Affiliates
free forum


Hàm chuyển đổi từ số thập phân (decimal) sang chữ

Go down

Hàm chuyển đổi từ số thập phân (decimal) sang chữ  Empty Hàm chuyển đổi từ số thập phân (decimal) sang chữ

Post  Admin Sat May 28, 2011 10:13 pm

public static string DecimalToString(decimal number)
{
string s = number.ToString("#");
string[] so = new string[] { "không", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín" };
string[] hang = new string[] { "", "nghìn", "triệu", "tỷ" };
int i, j, donvi, chuc, tram;
string str = " ";
bool booAm = false;
decimal decS = 0;

try
{
decS = Convert.ToDecimal(s.ToString());
}

catch { }

if (decS < 0)
{
decS = -decS;
s = decS.ToString();
booAm = true;
}

i = s.Length;
if (i == 0)
str = so[0] + str;
else
{
j = 0;

while (i > 0)
{
donvi = Convert.ToInt32(s.Substring(i - 1, 1));
i--;
if (i > 0)
chuc = Convert.ToInt32(s.Substring(i - 1, 1));
else
chuc = -1;
i--;
if (i > 0)
tram = Convert.ToInt32(s.Substring(i - 1, 1));
else
tram = -1;
i--;
if ((donvi > 0) || (chuc > 0) || (tram > 0) || (j == 3))
str = hang[j] + str;
j++;
if (j > 3) j = 1;
if ((donvi == 1) && (chuc > 1))
str = "một " + str;
else
{
if ((donvi == 5) && (chuc > 0))
str = "lăm " + str;
else if (donvi > 0)
str = so[donvi] + " " + str;
}
if (chuc < 0)
break;
else
{
if ((chuc == 0) && (donvi > 0)) str = "lẻ " + str;
if (chuc == 1) str = "mười " + str;
if (chuc > 1) str = so[chuc] + " mươi " + str;
}
if (tram < 0) break;
else
{
if ((tram > 0) || (chuc > 0) || (donvi > 0)) str = so[tram] + " trăm " + str;
}
str = " " + str;
}
}

if (booAm) str = "Âm " + str;
return str;
}
Admin
Admin
Admin

Tổng số bài gửi : 782
Join date : 2009-08-15

https://hackis.forumvi.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum