|
发表于 2013-3-4 04:32:31
|
显示全部楼层
本帖最后由 netegg 于 2013-3-4 04:48 编辑
[au3]#include <WinAPIEx.au3>
#include <array.au3>
$tFormat = _WinAPI_CreateNumberFormatInfo(0, 0, 4, '', ' ', 0)
$num = _WinAPI_GetNumberFormat(0, '15700970090560901', $tFormat)
$aNum = StringSplit($num, ' ', 2)
Local $aDigit[5] = ['', '万', '亿', '兆', '京']
Local $aDec[10] = ['0', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
$ret = ''
For $i = 0 To UBound($aNum) - 1
Switch StringLen($aNum[$i])
Case 4
$ret &= StringFormat('%s仟%s佰%s拾%s', $aDec[Number(StringLeft($aNum[$i], 1))], $aDec[Number(StringMid($aNum[$i], 2, 1))], $aDec[Number(StringMid($aNum[$i], 3, 1))], $aDec[Number(StringRight($aNum[$i], 1))]) & $aDigit[UBound($aNum) - 1- $i]
Case 3
$ret &= StringFormat('%s佰%s拾%s', $aDec[Number(StringLeft($aNum[$i], 1))], $aDec[Number(StringMid($aNum[$i], 2, 1))], $aDec[Number(StringRight($aNum[$i], 1))]) & $aDigit[UBound($aNum) - 1-$i]
Case 2
$ret &= StringFormat('%s拾%s', $aDec[Number(StringLeft($aNum[$i], 1))], $aDec[Number(StringRight($aNum[$i], 1))]) & $aDigit[UBound($aNum) - 1-$i]
Case 1
$ret &= StringFormat('%s', $aNum[$i]) & $aDigit[UBound($aNum) - 1-$i]
EndSwitch
Next
$ret = StringRegExpReplace($ret, '0[仟|佰|拾]', '0')
$ret = StringRegExpReplace($ret, '0{1,}', '零')
$ret = StringReplace($ret, '零兆', '兆')
$ret = StringReplace($ret, '零亿', '亿')
$ret = StringReplace($ret, '零万', '万')
$ret = StringReplace($ret, '零京', '京')
MsgBox(0, 0, $ret)[/au3]还有点问题 |
|