金额转换算法

换算|金额|算法|转换

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim str As String
str = Me.TextBox1.Text.Trim
Dim isfs As Boolean
If Left(str, 1) = "-" Then
isfs = True
str = str.Remove(0, 1)
Else
isfs = False
End If
Dim strpoint As String
Dim point() As String
Dim j As Int16
Dim jj() As String
Dim jjj As String
jjj = ""
If str.IndexOf(".") <> -1 Then
point = Split(str, ".", -1, CompareMethod.Text)
str = point(0)
strpoint = point(1)
ReDim jj(strpoint.Length - 1)
For j = 0 To strpoint.Length - 1
jj(j) = Left(strpoint, 1)
strpoint = Right(strpoint, strpoint.Length - 1)
jjj = jjj + convert(jj(j))
Next
End If
Dim strcode As String
strcode = ""
While strcode.Length <= str.Length
strcode = strcode & "2345" & "2346"
End While
strcode = "1" & strcode
strcode = Left(strcode, str.Length)
Dim i As Int16
Dim a() As String
Dim strcode1 As String
Dim countstr As Int16
Dim strcode2 As String
countstr = strcode.Length
ReDim a(strcode.Length - 1)
For i = 0 To countstr - 1
a(i) = Right(strcode, 1)
strcode = Left(strcode, strcode.Length - 1)
strcode1 = strcode1 & a(i)
strcode2 = strcode2 & "," & Mid(str, i + 1, 1) & Mid(strcode1, i + 1, 1)
Next
strcode2 = Right(strcode2, strcode2.Length - 1)
Dim newstr() As String
newstr = Split(strcode2, ",", -1, CompareMethod.Text)
Dim ii As Int16
Dim laststr As String
Dim strcode3 As String
Dim leftstr As String
Dim rightstr As String
For ii = 0 To newstr.Length - 1
strcode3 = newstr(ii)
leftstr = Left(strcode3, 1)
rightstr = Right(strcode3, 1)
rightstr = Replace(rightstr, rightstr, convert2(rightstr))
leftstr = Replace(leftstr, leftstr, convert(leftstr))
If leftstr = "零" And (rightstr = "拾" Or rightstr = "佰" Or rightstr = "仟") Then
rightstr = ""
End If
If leftstr = "零" And (rightstr = "万" Or rightstr = "亿") Then
leftstr = ""
End If
strcode3 = leftstr & rightstr
laststr = laststr & strcode3
Next
While laststr.IndexOf("佰零万") <> -1
laststr = laststr.Replace("零万", "万")
End While
While laststr.IndexOf("仟零零万") <> -1
laststr = laststr.Replace("零零万", "万")
End While
While laststr.IndexOf("零万") <> -1
laststr = laststr.Replace("零万", "零")
End While
While laststr.IndexOf("零亿") <> -1
laststr = laststr.Replace("零亿", "亿")
End While
While laststr.IndexOf("零零") <> -1
laststr = laststr.Replace("零零", "零")
End While
While Right(laststr, 1) = "零"
laststr = Left(laststr, laststr.Length - 1)
End While
If isfs = True Then
laststr = "负" & laststr
End If
If jjj = "" Then
TD2.InnerHtml = laststr
Else
If laststr = "" Then
TD2.InnerHtml = "零点" & jjj
Else
TD2.InnerHtml = laststr & "点" & jjj
End If
End If

End Sub

Function convert(ByVal num As String)
Select Case num
Case "1"
convert = "壹"

时间: 2025-01-21 00:55:13

金额转换算法的相关文章

Excel人民币小写金额转换大写技巧

要将人民币小写金额转换成大写格式,用Excel提供的格式,将自定义格式类型中的"[dbnum2]G/通用格式"改为"[dbnum2] G/通用格式"元""来实现.但在转换小数时却出现了问题,比如¥6,050.09只能转换为"陆仟零伍拾.零玖圆".那么用Excel能不能解决这一先天不足呢?其方法有以下两种(以下均对B1转换,假设B1是通过函数ROUND( )四舍五入取得二位小数的小写金额数,其值为¥6,050.09). 一.在三

javascript-想要实现的是小写金额转换成大写金额

问题描述 想要实现的是小写金额转换成大写金额 我想要实现的是小写金额转换成大写金额,下边是我在网上找到的JS代码,我想问的是,我是不是只要将"numberValue"我想转变的小写金额就可以啦,求大神指导,我的需求就是把表格中一项"大写金额"变成大写.其实大写金额就是JSP页面上ruKu.shiJiJinE的值,请问各位大神怎么写 <TR> <TD align="left" class="tdp">规格

javascript-实现的是小写金额转换成大写金额,求求大神啦,在线等

问题描述 实现的是小写金额转换成大写金额,求求大神啦,在线等 我想要实现的是小写金额转换成大写金额,下边是我在网上找到的JS代码,我想问的是,我是不是只要将"numberValue"我想转变的小写金额就可以啦,求大神指导,我的需求就是把表格中一项"大写金额"变成大写.其实大写金额就是JSP页面上ruKu.shiJiJinE的值,请问各位大神怎么写 <TR> <TD align="left" class="tdp&quo

用PHP实现小写金额转换大写金额的代码(精确到分)_php技巧

复制代码 代码如下: /** *数字金额转换成中文大写金额的函数 *String Int $num 要转换的小写数字或小写字符串 *return 大写字母 *小数位为两位 **/ function get_amount($num){ $c1 = "零壹贰叁肆伍陆柒捌玖"; $c2 = "分角元拾佰仟万拾佰仟亿"; $num = round($num, 2); $num = $num * 100; if (strlen($num) > 10) { return

asp.net(vb)实现金额转换成大写的函数_实用技巧

复制代码 代码如下: ''' <summary> ''' 将数据转换为Double数字 ''' </summary> ''' <param name="Obj"></param> ''' <returns></returns> ''' <remarks></remarks> Public Shared Function todbl(ByVal Obj As Object) As Double

javascript网页简体与繁体转换算法

网页特效网页简体与繁体转换算法 var defaultencoding = 2; // 1: var translatedelay = 0; var cookiedomain = "http://www.111cn.net"; //更改为你的博客网址 var msgtotraditionalchinese = "繁体"; //此处可以更改为你想要显示的文字 var msgtosimplifiedchinese = "简体";  //同上,但两处均

delphi实现小写金额转换

财务软件中总少不了大写的金额表示方式,如下为一个简单的小写金额转换为大写的函数,其思路简单(可以说烂吧,居然利用了位置来转换),但是它却几乎可以无限制的转换,只要你能读得出来和写得进去: function Tform1.SmallTOBig(small:real):string;var SmallMonth,BigMonth:string;wei1,qianwei1:string[2];wei,qianwei,dianweizhi,qian:integer;begin{------- 修改参数令

C#实现数字金额转换大写金额

代码的主调函数为ConvertSum,它的参数是string类型的数字字符串.在ASP.NET中调用方式如下: Label1.Text=ConvertSum("数字字符串"); 其代码如下:/// 转换数字金额主函数(包括小数) /// /// 数字字符串 /// 转换成中文大写后的字符串或者出错信息提示字符串 public string ConvertSum(string str) { if(!IsPositveDecimal(str)) return "输入的不是正数字!

进制转换算法原理(二进制 八进制 十进制 十六进制)_相关技巧

1.二进制数.八进制数.十六进制数转十进制数 有一个公式:二进制数.八进制数.十六进制数的各位数字分别乖以各自的基数的(N-1)次方,其和相加之和便是相应的十进制数.个位,N=1;十位,N=2...举例: 110B=1*2的2次方+1*2的1次方+0*2的0次方=0+4+2+0=6D 110Q=1*8的2次方+1*8的1次方+0*8的0次方=64+8+0=72D 110H=1*16的2次方+1*16的1次方+0*16的0次方=256+16+0=272D 2.十进制数转二进制数.八进制数.十六进制