您的位置:首页 > 其它

RDLC 中文数字转化函数

2013-11-07 15:09 197 查看
     在下面的文章中,我们将会介绍如何创建自定义函数,并且调用自己的新建的函数,本文以将 阿拉伯数字转换为中文为例

例如:

    参数:“16”

   转换后:十六

效果图如下:



函数源码:

'#############################################################################
'100以内转换函数
'
'函数名称:CNNumber
'参数:ls
'返回值:转换后的字符串
'
'整理人: ych
'版本历史
'2013-11-07
'#############################################################################

Shared Function CNNumber(ls As String)  As String
Dim len_ls As Long              ''字符串的长度
Dim ls_one As  String           ''去除前后空格的参数
Dim ge_ls AS String              ''个位数
Dim shi_is AS  String            ''十位数
Dim ls_number AS  String   ''转好后的中文数字
Dim ls_ge AS  Long              ''个位数数字
Dim ls_shi AS  Long              ''十位数数字
Dim ls_rtn  AS  String            ''返回值

ls_one =Trim(ls)
len_ls=Len(ls_one )

ls_number ="一二三四五六七八九"
ls_rtn  =""

If len_ls>1 Then           ''两位数
ls_shi  =Mid(ls_one ,1,1)
ls_ge =Mid(ls_one ,2,1)
Else        ''当数字为10以下
ge_ls =Mid(ls_number ,ls_one ,1)
End If

If ls_shi=1 And (ls_ge<1) Then    ''当数字为10时
shi_is ="十"
End If

If ls_shi=1 And (ls_ge>0) Then      ''当数字大于10小于20
shi_is ="十" +Mid(ls_number, ls_ge ,1)
End If

If (ls_shi>1) And (ls_ge>0) Then   ''当数字大于20且个位数不为0
shi_is =Mid(ls_number, ls_shi ,1) +"十"+Mid(ls_number, ls_ge ,1)
End If

If (ls_shi>1) And (ls_ge<1) Then   ''当数字大于19且个位数为0
shi_is =Mid(ls_number, ls_shi ,1) +"十"
End If

If len_ls>1 Then    ''两位数赋值
ls_rtn  = shi_is
Else                    ''一位数赋值
ls_rtn  =ge_ls
End If

CNNumber  =ls_rtn
End Function


具体步骤:

  1)单击报表空白处,然后单击菜单来报表,选择报表属性



2)单击代码标签,粘贴代码,然后确定



3)在报表新增一个文本框,然后右键



4)添加函数



整个过程就完了

由于是vb,不会,写起来蛮麻烦的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息