金額是否為零,為零則輸出「零元整」;不為零,則按照元、角、分單位進行分類處理
具體的思路分析如下:
【"元"處理】:
(演算法描述)整數部分是否為零,為零則輸出空值,不為零則轉換成大寫
if(trunc(abs(l13))=0,"",(text(trunc(round(abs(l13),2)),"[dbnum2]")&"元"))
(演算法描述)是否存在小數點,不存在,返回值為空;存在,則對角和分進行處理
if(iserr(search(".",round(abs(l13),2))),"",對角和分進行處理)
【對"角"處理】:
(演算法描述)整數部分是否為零,為零則輸出空值,不為零則轉換成大寫
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+1),1)="0","","對角進行處理")
【具體的語句】:
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+1),1)="0","",(text(right(trunc(round(abs(l13),2)*10)),"[dbnum2]")&"角"))
【"角"是否為零】:
mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+1),1)="0"
【對"角"進行處理】:
text(right(trunc(round(abs(l13),2)*10)),"[dbnum2]")&"角"
【對"分"處理】: (演算法描述)整數部分是否為零,為零則輸出空值,不為零則轉換成大寫
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+2),1)="0","","對分進行處理")
【具體的語句】:
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+2),1)="0","",text(right(trunc(round(abs(l13),2)*100)),"[dbnum2]")&"分")
【"分"是否為零】:
mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+2),1)="0"
【對"分"進行處理】:
text(right(trunc(round(abs(l13),2)*100)),"[dbnum2]")&"分"
【最後合成演算法】:
金額是否為零,為零則輸出「零元整」;
不為零,則按照元、角、分單位進行分類處理
(演算法描述)整數部分是否為零,為零則輸出空值,不為零則轉換成大寫
(演算法描述)是否存在小數點,不存在,返回值為空;存在,則對角和分進行處理
(演算法描述)整數部分是否為零,為零則輸出空值,不為零則轉換成大寫
(演算法描述)整數部分是否為零,為零則輸出空值,不為零則轉換成大寫
【最後合成的語句是】:
if(l13<0," 負","")
&if(l13=0,"零元",
(if(trunc(abs(l13))=0,"",(text(trunc(round(abs(l13),2)),"[dbnum2]")&"元"))&
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+1),1)="0","",(text(right(trunc(round(abs(l13),2)*10)),"[dbnum2]")&"角"))&
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+2),1)="0","",text(right(trunc(round(abs(l13),2)*100)),"[dbnum2]")&"分")))&"整"
【說明】:
1.其中 l13 是輸入小寫金額的單元格;
2.將上面的語句拷貝到其他(非l13)單元格,並在語句的最前面新增 = 就可以了使用了,即 :
=if(l13<0," 負","")
&if(l13=0,"零元",
(if(trunc(abs(l13))=0,"",(text(trunc(round(abs(l13),2)),"[dbnum2]")&"元"))&
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+1),1)="0","",(text(right(trunc(round(abs(l13),2)*10)),"[dbnum2]")&"角"))&
if(mid(text(round(abs(l13),2),"0.00"),(search(".",text(abs(l13),"0.00"))+2),1)="0","",text(right(trunc(round(abs(l13),2)*100)),"[dbnum2]")&"分")))&"整"
小寫金額轉換成中文大寫金額
public string cmycurd decimal num str2 str2.substring 15 j 取出對應位數的str2的值。如 200.55,j為5所以str2 佰拾元角分 迴圈取出每一位需要轉換的值 for i 0 i j i else else else else else...
小寫金額轉換成大寫
原作在sql 2000中有一些問題。修正錯誤並在sql 2000中執行通過。set nocount on select v lowerstr ltrim rtrim str n lowermoney,20,2 四捨五入為指定的精度並刪除資料左右空格 select i i 1 select v upp...
小寫金額轉換成大寫 sql server
if exists select from dbo.sysobjects where id object id n dbo l2u andxtype in n fn n if n tf drop function dbo l2u go create function dbo.l2u n lowerm...