ITPub博客

首页 > IT职业 > IT生活 > Notes中人民币大写换算的实现 (转)

Notes中人民币大写换算的实现 (转)

原创 IT生活 作者:amyz 时间:2007-10-14 14:59:37 0 删除 编辑
Notes中人民币大写换算的实现 (转)[@more@]

'调用按钮的代码:
Sub Click(source As Button)
 Dim w As New notesUIWorkspace 
 Dim ui As notesUIdocument
 Dim jineStr As String
 
 Set ui = w.currentDocument
 Call ui.refresh
 jineStr = ui.fieldGetText("jine")
 Call ui.fieldSetText("dxje",TurnResult(jineStr))
 Call ui.refresh
End Sub


'换算函数
Function TurnResult(numStr As String) As String
 Dim digi As Integer
 Dim numLen As Integer
 
 numLen = Len(numStr)
 intStr = Left(numStr,(numLen - 3)) '取整数部分
 digStr = Right(numStr,2) '取小数部分
 
 numLen = Len(intStr)
 digi_old = 9
 '处理整数部分转换
 While numLen <> 0
 digi = Cint(Left(intStr,1))
 If numLen<5 Then '完元以下的换算
 If digi_old = 0 And digi = 0 And numLen<>1 Then
 TurnResult = TurnResult
 Else
 If digi = 0 And numLen <> 1 Then
 TurnResult = TurnResult + numToBigWrite(digi)
 Elseif digi = 0 And digi_old = 0 And numLen = 1  Then
 TurnResult = Left(TurnResult,Len(TurnResult)-1) + Unit(numLen)
 Elseif digi = 0 And digi_old <> 0 And numLen = 1  Then
 TurnResult = TurnResult + Unit(numLen)
 Else
 TurnResult = TurnResult + numToBigWrite(digi) + Unit(numLen)
 End If
 End If
 Else '万元以上的换算
 If digi_old = 0 And digi = 0 And numLen<>5 Then
 TurnResult = TurnResult
 Else
 If digi = 0 And numLen <> 5 Then
 TurnResult = TurnResult + numToBigWrite(digi)
 Elseif digi = 0 And digi_old = 0 And numLen = 5  Then
 TurnResult = Left(TurnResult,Len(TurnResult)-1) + Unit(numLen)
 Elseif digi = 0 And digi_old <> 0 And numLen = 5  Then
 TurnResult = TurnResult + Unit(numLen)
 Else
 TurnResult = TurnResult + numToBigWrite(digi) + Unit(numLen)
 End If
 End If
 End If
 
 digi_old = digi
 intStr = Right(intStr,numLen - 1)
 numLen = Len(intStr)
 Wend
 '小数部分的数值转换
 TurnResult = TurnResult + numToBigWrite(Cint(Left(digStr,1))) + Unit(-1) + _
 numToBigWrite(Cint(Right(digStr,1))) + Unit(-2) + "整"
 
End Function


'单位转换函数
Function Unit(bit As Integer) As String
 select Case bit
 Case -1
 Unit="角"
 Case -2
 Unit="分"
 Case 1
 Unit="元"
 Case 2
 Unit="拾"
 Case 3
 Unit="佰"
 Case 4
 Unit="仟"
 Case 5
 Unit="万"
 Case 6
 Unit="拾" 
 Case 7
 Unit="佰"
 Case 8
 Unit="仟" 
 Case 9
 Unit="亿"
 Case Else
 Unit="无效"+Cstr(bit)
 End Select 
End Function


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752019/viewspace-976538/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3984
  • 访问量
    7334899