表控件ActiveReports快速入门指南:如何应用脚本?

脚本函数使用Visual Basic .NET编程语言,下面是一个自定义脚本函数的例子:

 表控件ActiveReports快速入门指南:如何应用脚本 class=
1. 在脚本选项卡中输入正确的函数

该函数用于实现将数字转换为中文大写功能,供参考。

Function ConvertToRMB(ByVal inputString As String) As StringDim numList As String = "零壹贰叁肆伍陆柒捌玖"Dim rmbList As String = "分角元拾佰仟万拾佰仟亿拾佰仟万"Dim number As Double = 0Dim tempOutString As String = ""number = Double.Parse(inputString)Dim tempNumberString As String = Convert.ToInt64(number * 100).ToString()Dim tempNmberLength As Integer = tempNumberString.LengthDim i As Integer = 0While i < tempNmberLengthDim oneNumber As Integer = Int32.Parse(tempNumberString.Substring(i, 1))Dim oneNumberChar As String = numList.Substring(oneNumber, 1)Dim oneNumberUnit As String = rmbList.Substring(tempNmberLength - i - 1, 1)If Not (oneNumberChar = "零") ThentempOutString += oneNumberChar + oneNumberUnitElseIf oneNumberUnit = "亿" OrElse oneNumberUnit = "万" OrElse oneNumberUnit = "元" OrElse oneNumberUnit = "零" ThenWhile tempOutString.EndsWith("零")tempOutString = tempOutString.Substring(0, tempOutString.Length - 1)End WhileEnd IfIf oneNumberUnit = "亿" OrElse (oneNumberUnit = "万" AndAlso Not tempOutString.EndsWith("亿")) OrElse oneNumberUnit = "元" ThentempOutString += oneNumberUnitElseIf Not tempOutString Is Nothing ThenDim tempEnd As Boolean = tempOutString.EndsWith("亿")Dim zeroEnd As Boolean = tempOutString.EndsWith("零")If tempOutString.Length > 1 ThenDim zeroStart As Boolean = tempOutString.Substring(tempOutString.Length - 2, 2).StartsWith("零")If Not zeroEnd AndAlso (zeroStart OrElse Not tempEnd) ThentempOutString += oneNumberCharEnd IfElseIf Not zeroEnd AndAlso Not tempEnd ThentempOutString += oneNumberCharEnd IfEnd IfEnd IfEnd IfEnd Ifi += 1End WhileIf Not tempOutString Is Nothing ThenWhile tempOutString.EndsWith("零")tempOutString = tempOutString.Substring(0, tempOutString.Length - 1)End WhileWhile tempOutString.EndsWith("元")tempOutString = tempOutString + "整"End WhileReturn tempOutStringElseReturn ""End IfEnd Function

 表控件ActiveReports快速入门指南:如何应用脚本 class=
2.在单元格(文本框)中引用函数

在单元格(文本框)中引用函数,设置单元格 Value 属性(注意:凡是支持【表达式】的属性均可调用脚本函数)。

调用形式是:Code.函数名(参数列表) ,

= Code.ConvertToRMB(Fields!Bonus.Value)

 表控件ActiveReports快速入门指南:如何应用脚本 class=
3. 预览

 表控件ActiveReports快速入门指南:如何应用脚本 class=  表控件ActiveReports快速入门指南:如何应用脚本 class=

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2023年1月6日
下一篇 2023年1月7日

相关推荐

发表回复

登录后才能评论