# 记号

stringvar NumberStr:="$1000.26";//传入数据必须2位小数,是0=0.00的格式 //去掉,的字符 Global Stringvar CancelNumberStr:=Replace(NumberStr,",",""); //去掉&号 CancelNumberStr:=Replace(CancelNumberStr,"$",""); //整数 stringvar IntNumberStr:=Left(CancelNumberStr, InStr (CancelNumberStr, ".")-1); //小数 StringVar DecNumber := Right (CancelNumberStr, Length (CancelNumberStr) - InStr (CancelNumberStr, ".")); DecNumber :=Mid(DecNumber,1,2); stringVar intResult;//整数部分的金额数据字符 if tonumber(IntNumberStr)<>0 then ( //整数捕部分大写数组 stringVar Array IntUpperStr; numberVar i; Redim IntUpperStr[length(IntNumberStr)]; For i := 1 To length(IntNumberStr) Do ( If Mid(IntNumberStr,i,1)="0" Then IntUpperStr[i]:="零" Else If Mid(IntNumberStr,i,1)="1" Then IntUpperStr[i]:="壹" Else If Mid(IntNumberStr,i,1)="2" Then IntUpperStr[i]:="贰" Else If Mid(IntNumberStr,i,1)="3" then IntUpperStr[i]:="叁" Else If Mid(IntNumberStr,i,1)="4" then IntUpperStr[i]:="肆" Else If Mid(IntNumberStr,i,1)="5" then IntUpperStr[i]:="伍" Else If Mid(IntNumberStr,i,1)="6" then IntUpperStr[i]:="陆" Else If Mid(IntNumberStr,i,1)="7" then IntUpperStr[i]:="柒" Else If Mid(IntNumberStr,i,1)="8" then IntUpperStr[i]:="捌" Else If Mid(IntNumberStr,i,1)="9" then IntUpperStr[i]:="玖" ); StringVar Array intDotUnit; intDotUnit := ["元","拾","佰","仟","萬","拾","佰","仟","億","拾","佰","仟","万","拾","佰","仟"]; // 在大寫金額數字中加入單位 (整數位) intResult:=""; Local NumberVar j; Local NumberVar k := 1; For j := length(IntNumberStr) To 1 Step -1 Do ( If (IntUpperStr[j]="零" and intDotUnit[k] = "元") then intResult := intDotUnit[k]+intResult Else If (IntUpperStr[j]="零" and intDotUnit[k]<> "元") then intResult := IntUpperStr[j]+intResult Else intResult := IntUpperStr[j]+intDotUnit[k]+intResult; k:=k+1; ); //去掉"零零"换 intResult:=Replace(intResult,"零零","零"); ) else intResult:=""; //处理小数大写 stringvar Array DecUpperStr; Redim DecUpperStr[2]; For i := 1 To 2 Do ( If Mid(DecNumber,i,1)="0" Then DecUpperStr[i]:="零" Else If Mid(DecNumber,i,1)="1" Then DecUpperStr[i]:="壹" Else If Mid(DecNumber,i,1)="2" Then DecUpperStr[i]:="贰" Else If Mid(DecNumber,i,1)="3" then DecUpperStr[i]:="叁" Else If Mid(DecNumber,i,1)="4" then DecUpperStr[i]:="肆" Else If Mid(DecNumber,i,1)="5" then DecUpperStr[i]:="伍" Else If Mid(DecNumber,i,1)="6" then DecUpperStr[i]:="陆" Else If Mid(DecNumber,i,1)="7" then DecUpperStr[i]:="柒" Else If Mid(DecNumber,i,1)="8" then DecUpperStr[i]:="捌" Else If Mid(DecNumber,i,1)="9" then DecUpperStr[i]:="玖" ); //处理角的时候 if DecUpperStr[1]="零" then DecUpperStr[1]:=DecUpperStr[1] else DecUpperStr[1]:=DecUpperStr[1]+"角"; //处理分的时候 if DecUpperStr[2]="零" then DecUpperStr[2]:= DecUpperStr[2] else DecUpperStr[2]:=DecUpperStr[2]+"分"; //小数部分n角n分 stringvar DecResult; DecResult:=DecUpperStr[1]+DecUpperStr[2]; if DecResult="零零" then DecResult:="" else if DecUpperStr[1]<>"零" and DecUpperStr[2]="零" then DecResult:=DecUpperStr[1] else if DecUpperStr[1]="零" and DecUpperStr[2]<>"零" then DecResult:=DecUpperStr[2]; //去掉"零零"换 numbervar Zi; For Zi:=1 To Length(intResult) Do ( intResult:=Replace(intResult,"零零","零") ); //输出结果 if(intResult="" and DecResult="") then totext("零元") else totext(intResult+DecResult+"整");