小写金额如何转大写?

发布网友 发布时间:2022-04-06 03:33

我来回答

6个回答

热心网友 时间:2022-04-06 05:02

=IF((INT(G16*10)-INT(G16)*10)=0,TEXT(INT(G16),"[DBNum2]G/通用格式")&"元"&IF((INT(G16*100)-INT((G16)*10)*10)=0,"整","零"&TEXT(INT(G16*100)-INT(G16*10)*10,"[DBNum2]G/通用格式")&"分"),TEXT(INT(G16),"[DBNum2]G/通用格式")&"元"&IF((INT(G16*100)-INT((G16)*10)*10)=0,TEXT((INT(G16*10)-INT(G16)*10),"[DBNum2]G/通用格式")&"角整",TEXT((INT(G16*10)-INT(G16)*10),"[DBNum2]G/通用格式")&"角"&TEXT(INT(G16*100)-INT(G16*10)*10,"[DBNum2]G/通用格式")&"分"))

你把这个公式复制到EXCEL表格中,然后在单元格G16中输入你要的数字(阿拉伯数字),不需要vba的

热心网友 时间:2022-04-06 06:20

以下是一段用VBA代码编写的金额小写转大写的函数:
public function zdx(x as currency) as string
dim lnp as integer
dim prc as string
dim tmp as string
dim nob as currency
dim dx as string
dim xx as string
dim zhen as boolean
dim str(10) as string
dim china as string
china = "分角元拾佰仟万拾佰仟亿"
str(0) = "零"
str(1) = "壹"
str(2) = "贰"
str(3) = "叁"
str(4) = "肆"
str(5) = "伍"
str(6) = "陆"
str(7) = "柒"
str(8) = "捌"
str(9) = "玖"
zhen = true
x = formatnumber(x, 2)
prc = cstr(x)
prc = replace(prc, ",", "")
lnp = len(prc)
for i = lnp - 1 to 1 step -1
if mid(prc, i, 1) = "." then
select case lnp - i
case 1
prc = replace(prc, ".", "") + "0"
case 2
prc = replace(prc, ".", "")
end select
zhen = false
exit for
end if
next i
if zhen then prc = prc + "00"
lnp = len(prc)
for i = 1 to lnp
tmp = str(mid(prc, i, 1)) & tmp
next i
zdx = ""
fy = 1
for i = 1 to lnp
xx = mid(tmp, i, 1)
dx = mid(china, i, 1)
if xx <> "零" then
zdx = xx & dx & zdx
f = 1
else
if i = 3 then
zdx = dx & zdx
end if
if i = 7 then
zdx = dx & zdx
end if
if f then
zdx = "零" & zdx
end if
f = 0
end if
next i
if zhen then zdx = zdx + "正"
zdx = replace(zdx, "零万", "万")
zdx = replace(zdx, "零元", "元")
end function

热心网友 时间:2022-04-06 07:55

哈哈,我们老师的一道课堂作业题。
校园网太慢了,我都给你下下来了,一定要给我分哦!

#include <iostream.h>
#include <string.h>
#define MAXLEN 10 * 2 * 2 + 1 //结果数组最大长度,10个数字,10个单位,每个汉字占两个字节,加上一个结束符

char *GetMoneyUpper(int money)
{
//超过规定范围
if (money < 0 || money >= 1e10) return NULL;
//数字的中文表示
char number[][3] = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "染", "捌", "玖"};
//单位的中文表示
char unit[][3] = {"圆", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾"};
//人民币大写中间结果
char result[MAXLEN]; //结果字符串数组
int i = MAXLEN - 1; //用于记住当前下标
result[i] = '\0'; //字符串结束符
i--;
int u = 0; //当前单位下标
while (money > 0)
{
int n = money % 10; //取最低位
int len = strlen(unit[u]); //当前单位的中文长度
i -= len; //将结果数组下标向前推
strncpy(&result[i], unit[u], len); //将当前单位字符串拷贝到对应位置,这里不能用strcpy,strcpy会将'\0'拷贝到最后,字符串就会断
len = strlen(number[n]); //当前数字的中文长度
i -= len; //将结果数组下标向前推
strncpy(&result[i], number[n], len);//将当前数字字符串拷贝到对应位置
u++; //单位升位
money /= 10; //去掉刚才已经处理过的数字
}
char *strMoney = new char[strlen(&result[i])+1];
strcpy(strMoney, &result[i]);
return strMoney;
}

void main()
{
int money;
do
{
cout << "请输入人民币金额小写数字:";
cin >> money;
char *pMoney = GetMoneyUpper(money);
if (pMoney != NULL)
{
cout << "对应的人民币金额大写形式为:" << pMoney << " " << endl;
delete[] pMoney;
}
}while (money > 0);
}

热心网友 时间:2022-04-06 09:46

=IF((INT(G16*10)-INT(G16)*10)=0,TEXT(INT(G16),"[DBNum2]G/通用格式")&"元"&IF((INT(G16*100)-INT((G16)*10)*10)=0,"整","零"&TEXT(INT(G16*100)-INT(G16*10)*10,"[DBNum2]G/通用格式")&"分"),TEXT(INT(G16),"[DBNum2]G/通用格式")&"元"&IF((INT(G16*100)-INT((G16)*10)*10)=0,TEXT((INT(G16*10)-INT(G16)*10),"[DBNum2]G/通用格式")&"角整",TEXT((INT(G16*10)-INT(G16)*10),"[DBNum2]G/通用格式")&"角"&TEXT(INT(G16*100)-INT(G16*10)*10,"[DBNum2]G/通用格式")&"分"))

热心网友 时间:2022-04-06 11:54

选中小写的那栏数字,右键--设置单元格格式--特殊--中文大写数字

热心网友 时间:2022-04-06 14:19

用VB我会,Excel...算了

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com