ACCESS数据库如可把合计金额转换成大写

ACCESS数据库如可把合计金额转换成大写,第1张

给你2个连接

关于此主题请参考:

如何将人民币小写金额转为大写?大小写转换(一)《VBA》

http://access911.net/index.asp?u1=a&u2=71FAB21E

关于此主题请参考:

如何将人民币小写金额转为大写?大小写转换(二)《VBA》

http://access911.net/index.asp?u1=a&u2=73FAB21E

给你2个函数

Function shit(shit1 As Variant) As String

'此函数将阿拉伯数字转换为大写金额数,其中调用了 yahoo函数

On Error GoTo err_handle

Dim rem_thousand As Single '千位以后

Dim dec_num '小数点以后

Dim shit2

Dim shit3 As String

Dim I As Integer

Dim declen As Integer

shit = ""

'shit2 = Trim(Str(Abs(shit1)))

If IsNull(shit1) Then

shit1 = 0

End If

shit2 = Trim(Format(Abs(shit1), "0.00"))

declen = Len(Format(Str(Abs(shit2)), "0.00")) - 3 '3是小数点及以后2位

If declen <= 4 Then

shit = shit + yahoo(Mid(shit2, 1, declen))

Else

shit3 = Trim(Str(Val(Mid(shit2, declen - 3, 4))))

' MsgBox Str(Len(shit3)) + "," + shit3

If Mid(shit2, declen - 3, 1) = "0" Then

If Val(shit3) = 0 Then

shit = shit + yahoo(Mid(shit2, 1, declen - 4)) + "万" + yahoo(shit3)

Else

shit = shit + yahoo(Mid(shit2, 1, declen - 4)) + "万零" + yahoo(shit3)

End If

Else

shit = shit + yahoo(Mid(shit2, 1, declen - 4)) + "万" + yahoo(shit3)

End If

End If

If Abs(shit1) >= 1 Then

shit = shit + "元"

End If

'==================

'小数点以后

'dec_num = (shit1 - Fix(shit1)) * 100

dec_num = Val(Right(Format(Str(Abs(shit2)), "0.00"), 2))

' MsgBox Right(Trim(Str(shit1)), 2)

If (dec_num Mod 10) = 0 Then

If (dec_num \ 10) <> 0 Then

shit = shit + chn(dec_num \ 10) + "角"

End If

Else

If (dec_num \ 10) <> 0 Then

shit = shit + chn(dec_num \ 10) + "角" + chn(dec_num Mod 10) + "分"

Else

shit = shit + chn(dec_num \ 10) + chn(dec_num Mod 10) + "分"

End If

End If

'===================

shit = shit + "整"

If shit1 = 0 Then

shit = "零元整"

End If

err_exit:

Exit Function

err_handle:

MsgBox "发生错误!请找原因"

GoTo err_exit

End Function

Function chn(shit2 As Integer) As String

Select Case shit2

Case 1

chn = "壹"

Case 2

chn = "贰"

Case 3

chn = "叁"

Case 4

chn = "肆"

Case 5

chn = "伍"

Case 6

chn = "陆"

Case 7

chn = "柒"

Case 8

chn = "捌"

Case 9

chn = "玖"

Case 0

chn = "零"

End Select

End Function

Function yahoo(yaa As String) As String

'此函数被shit()调用

Dim shit_len

Dim num(5) As Integer

shit_len = Len(yaa)

For I = 1 To shit_len

num(I) = Mid(yaa, shit_len - I + 1, 1)

Next I

yahoo = ""

Select Case shit_len

Case 1 '元

If num(1) <> 0 Then

yahoo = yahoo + chn(num(1))

End If

'MsgBox yahoo

Case 2 '十

If num(1) <> 0 Then

yahoo = yahoo + chn(num(2)) + "拾" + chn(num(1))

Else

yahoo = yahoo + chn(num(2)) + "拾"

End If

Case 3 '百

If num(1) = 0 Then

If num(2) = 0 Then

yahoo = yahoo + chn(num(3)) + "佰"

Else

yahoo = yahoo + chn(num(3)) + "佰" + chn(num(2)) + "拾"

End If

Else

If num(2) = 0 Then

yahoo = yahoo + chn(num(3)) + "佰零" + chn(num(1))

Else

yahoo = yahoo + chn(num(3)) + "佰" + chn(num(2)) + "拾" + chn(num(1))

End If

End If

Case 4 '千

If num(1) = 0 Then

If num(2) = 0 Then

If num(3) = 0 Then

yahoo = yahoo + chn(num(4)) + "仟"

Else

yahoo = yahoo + chn(num(4)) + "仟" + chn(num(3)) + "佰"

End If

Else

If num(3) = 0 Then

yahoo = yahoo + chn(num(4)) + "仟零" + chn(num(2)) + "拾"

Else

yahoo = yahoo + chn(num(4)) + "仟" + chn(num(3)) + "佰" + chn(num(2)) + "拾"

End If

End If

Else

If num(2) = 0 Then

If num(3) = 0 Then

yahoo = yahoo + chn(num(4)) + "仟零" + chn(num(1))

Else

yahoo = yahoo + chn(num(4)) + "仟" + chn(num(3)) + "佰零" + chn(num(1))

End If

Else

If num(3) = 0 Then

yahoo = yahoo + chn(num(4)) + "仟零" + chn(num(2)) + "拾" + chn(num(1))

Else

yahoo = yahoo + chn(num(4)) + "仟" + chn(num(3)) + "佰" + chn(num(2)) + "拾" + chn(num(1))

End If

End If

End If

End Select

End Function

用函数upper就可以处理了

UPPER

返回将小写字符数据转换为大写的

字符表达式

---更新:

update

表名

set

字段名

=

UPPER(字段名)

where

查询条件

---查询:

select

UPPER(字段名)

from

表名

如果只是希望输入的内容自动变大写,那么spring mvc 可以使用initbinder功能。可以自动将输入进行大写转换。 如果要在写数据前处理的话,需要aop来控制一下,快速的将bean中所有字段转换成大写,有个java工具叫 Dozer。功能很强。

后台IBATIS,那么可以typehandle来实现。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10007550.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-04
下一篇 2023-05-04

发表评论

登录后才能评论

评论列表(0条)

保存