如何将241转换成大写的数值? 如何将241转换成大写的数值? 如:贰佰肆十壹? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/t/20030927/16/2307476.html public string convertToChineseMoney(decimal num){ string strChina = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字 string strUnit = "万仟佰拾亿仟佰拾万仟佰拾元角分"; //数字位所对应的汉字 string strSingleNum = ""; //从原num值中取出的值 string strNum = ""; //数字的字符串形式 string strResult = ""; //人民币大写金额形式 string chChina= ""; //数字的汉语读法 string chUnit = ""; //数字位的汉语读法 int i; //循环变量 int lenth; //num的值乘以100的字符串长度 int nZero = 0; //用来计算连续的零值是几个 int temp; //从原num值中取出的值 num = Math.Round(Math.Abs(num),2); //将num取绝对值并四舍五入取2位小数 strNum = ((long)(num*100)).ToString(); //将num乘100并转换成字符串形式 lenth = strNum.Length; //找出最高位 if (lenth > 15) { return "位数过大,无法转换!"; } //取出对应位数的strUnit的值。如:200.55,lenth为5所以strUnit=佰拾元角分 strUnit = strUnit.Substring(15-lenth); //循环取出每一位需要转换的值 for(i=0;i<lenth;i++) { strSingleNum = strNum.Substring(i,1); //取出需转换的某一位的值 temp = Convert.ToInt32(strSingleNum); //转换为数字 if (i != (lenth-3) && i != (lenth-7) && i != (lenth-11) && i != (lenth-15)) { //当所取位数不为元、万、亿、万亿上的数字时 if (strSingleNum == "0") { chChina = ""; chUnit = ""; nZero = nZero + 1; } else { if(strSingleNum != "0" && nZero != 0) { chChina = "零" + strChina.Substring(temp,1); chUnit = strUnit.Substring(i,1); nZero = 0; } else { chChina = strChina.Substring(temp,1); chUnit = strUnit.Substring(i,1); nZero = 0; } } } else { //该位是万亿,亿,万,元位等关键位 if (strSingleNum != "0" && nZero != 0) { chChina = "零" + strChina.Substring(temp,1); chUnit = strUnit.Substring(i,1); nZero = 0; } else { if (strSingleNum != "0" && nZero == 0) { chChina = strChina.Substring(temp,1); chUnit = strUnit.Substring(i,1); nZero = 0; } else { if (strSingleNum == "0" && nZero >= 3) { chChina = ""; chUnit = ""; nZero = nZero + 1; } else { if (lenth >= 11) { chChina = ""; nZero = nZero + 1; } else { chChina = ""; chUnit = strUnit.Substring(i,1); nZero = nZero + 1; } } } } } if (i == (lenth-11) || i == (lenth-3)) { //如果该位是亿位或元位,则必须写上 chUnit = strUnit.Substring(i,1); } strResult = strResult + chChina + chUnit; if (i == lenth-1 && strSingleNum == "0" ) { //最后一位(分)为0时,加上“整” strResult = strResult + '整'; } } if (num == 0) { strResult = "零元整"; } return strResult;} 应用模板页后内容也显示有问题 GridView 外层 div asp.net webgame源码? masterpage.master中内容为什么不能居顶问题 ASP.NET中的框架FRAMESET问题? 取Panel里的控件问题。 怎么写SQL语句怎么把所有的东西都查询出来了?? 关于附件的保存问题 数据库问题 请问,php中有一个eval()函数,asp.net中有类似的函数吗? 看不懂这这个错误希望有高手来帮忙解答下 SQL 只可以写入数据。不可以把以前数据覆盖掉怎么写SQL 语句
{
string strChina = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字
string strUnit = "万仟佰拾亿仟佰拾万仟佰拾元角分"; //数字位所对应的汉字
string strSingleNum = ""; //从原num值中取出的值
string strNum = ""; //数字的字符串形式
string strResult = ""; //人民币大写金额形式
string chChina= ""; //数字的汉语读法
string chUnit = ""; //数字位的汉语读法 int i; //循环变量
int lenth; //num的值乘以100的字符串长度
int nZero = 0; //用来计算连续的零值是几个
int temp; //从原num值中取出的值
num = Math.Round(Math.Abs(num),2); //将num取绝对值并四舍五入取2位小数
strNum = ((long)(num*100)).ToString(); //将num乘100并转换成字符串形式
lenth = strNum.Length; //找出最高位 if (lenth > 15)
{
return "位数过大,无法转换!";
}
//取出对应位数的strUnit的值。如:200.55,lenth为5所以strUnit=佰拾元角分
strUnit = strUnit.Substring(15-lenth);
//循环取出每一位需要转换的值
for(i=0;i<lenth;i++)
{
strSingleNum = strNum.Substring(i,1); //取出需转换的某一位的值
temp = Convert.ToInt32(strSingleNum); //转换为数字
if (i != (lenth-3) && i != (lenth-7) && i != (lenth-11) && i != (lenth-15))
{
//当所取位数不为元、万、亿、万亿上的数字时
if (strSingleNum == "0")
{
chChina = "";
chUnit = "";
nZero = nZero + 1;
}
else
{
if(strSingleNum != "0" && nZero != 0)
{
chChina = "零" + strChina.Substring(temp,1);
chUnit = strUnit.Substring(i,1);
nZero = 0;
}
else
{
chChina = strChina.Substring(temp,1);
chUnit = strUnit.Substring(i,1);
nZero = 0;
}
}
}
else
{
//该位是万亿,亿,万,元位等关键位
if (strSingleNum != "0" && nZero != 0)
{
chChina = "零" + strChina.Substring(temp,1);
chUnit = strUnit.Substring(i,1);
nZero = 0;
}
else
{
if (strSingleNum != "0" && nZero == 0)
{
chChina = strChina.Substring(temp,1);
chUnit = strUnit.Substring(i,1);
nZero = 0;
}
else
{
if (strSingleNum == "0" && nZero >= 3)
{
chChina = "";
chUnit = "";
nZero = nZero + 1;
}
else
{
if (lenth >= 11)
{
chChina = "";
nZero = nZero + 1;
}
else
{
chChina = "";
chUnit = strUnit.Substring(i,1);
nZero = nZero + 1;
}
}
}
}
} if (i == (lenth-11) || i == (lenth-3))
{
//如果该位是亿位或元位,则必须写上
chUnit = strUnit.Substring(i,1);
} strResult = strResult + chChina + chUnit;
if (i == lenth-1 && strSingleNum == "0" )
{
//最后一位(分)为0时,加上“整”
strResult = strResult + '整';
}
}
if (num == 0)
{
strResult = "零元整";
}
return strResult;
}