您好,欢迎光临本网站![请登录][注册会员]  
文件名称: vb数字、金额大写转换
  所属分类: VB
  开发工具:
  文件大小: 3kb
  下载次数: 0
  上传时间: 2010-05-16
  提 供 者: xgx19*****
 详细说明: Const strN = "零壹贰叁肆伍陆柒捌玖" Const strG = "拾佰仟万亿" Const intN = "0123456789" Dim Zero_Count As Long '读零计数 ' Private Function GetN(ByVal N As Long) As String GetN = Mid(strN, N + 1, 1) End Function Private Function GetG(ByVal G As Long) As String Select Case G Case 1 GetG = "" Case 2, 6 GetG = Mid(strG, 1, 1) Case 3, 7 GetG = Mid(strG, 2, 1) Case 4, 8 GetG = Mid(strG, 3, 1) Case 5 GetG = Mid(strG, 4, 1) Case 9 GetG = Mid(strG, 5, 1) End Select End Function Private Function ReadLongNumber(ByVal LongX As String) As String Dim NumberX As String Dim l As Long '长度 Dim m As Long '多余位数 Dim c As Long '循环次数 Dim i As Long, j As Long '标志 Dim CurN As String NumberX = LongX l = Len(NumberX) Do Until l < 9 m = l Mod 8 If m = 0 Then m = 8 CurN = Left(NumberX, m) If ReadIntNumber(CurN) <> "零" Then ReadLongNumber = ReadLongNumber & ReadIntNumber(CurN) & "亿" Else ReadLongNumber = ReadLongNumber & "亿" End If NumberX = Right(NumberX, Len(NumberX) - m) l = Len(NumberX) Loop ReadLongNumber = ReadLongNumber & ReadIntNumber(NumberX) If Len(ReadLongNumber) > 2 And Right(ReadLongNumber, 1) = "零" Then '去尾 零 ReadLongNumber = Left(ReadLongNumber, Len(ReadLongNumber) - 1) End If If Mid(ReadLongNumber, 1, 2) = "壹拾" Then '掐头 壹拾 ReadLongNumber = Right(ReadLongNumber, Len(ReadLongNumber) - 1) Mid(ReadLongNumber, 1, 1) = "拾" End If Zero_Count = 0 End Function Private Function ReadIntNumber(ByVal NumberX As String) As String Dim l As Long '长度 Dim m As Long '多余位数 Dim c As Long '循环次数 Dim i As Long, j As Long '标志 Dim CurN As String If Val(NumberX) = 0 Then ReadIntNumber = GetN(0): Exit Function l = Len(NumberX) If l > 8 Then Exit Function m = l Mod 9 CurN = Right(NumberX, m) For i = Len(CurN) To 1 Step -1 If GetN(Int(Mid(CurN, i, 1))) = "零" And Zero_Count = 1 Then If GetG(Len(CurN) - i + 1) = "万" Then If (Not (Val(Left(CurN, Len(CurN) - 5)) = 0)) Then ReadIntNumber = GetG(Len(CurN) - i + 1) & ReadIntNumber End If Else If GetN(Int(Mid(CurN, i, 1))) = "零" Then ReadIntNumber = GetN(Int(Mid(CurN, i, 1))) & ReadIntNumber If GetG(Len(CurN) - i + 1) = "万" Then If (Not (Val(Left(CurN, Len(CurN) - 5)) = 0)) Then ReadIntNumber = GetG(Len(CurN) - i + 1) & ReadIntNumber End If Zero_Count = 1 Else ReadIntNumber = GetG(Len(CurN) - i + 1) & ReadIntNumber ReadIntNumber = GetN(Int(Mid(CurN, i, 1))) & ReadIntNumber Zero_Count = 0 End If End If Next i 'Loop If Len(ReadIntNumber) > 2 And Right(ReadIntNumber, 1) = "零" Then '去尾零 ReadIntNumber = Left(ReadIntNumber, Len(ReadIntNumber) - 1) End If If Mid(ReadIntNumber, 1, 2) = "壹拾" Then '掐头 壹拾 ReadIntNumber = Right(ReadIntNumber, Len(ReadIntNumber) - 1) Mid(ReadIntNumber, 1, 1) = "拾" End If End Function Public Function ReadNumber(ByVal NumberX As String) As String Dim LongX As String Dim PointX As String Dim LongLong As Long Dim bFS As Boolean '负数 If Not IsNumeric(NumberX) Then ReadNumber = "" Exit Function End If If CDbl(NumberX) < 0 Then NumberX = -NumberX bFS = True End If NumberX = CStr(Format(NumberX, "General Number")) LongLong = InStr(1, NumberX, ".") If LongLong <> 0 Then ReadNumber = ReadLongNumber(Left(NumberX, LongLong - 1)) ReadNumber = ReadNumber & "点" & ReadSmallNumber(Right(NumberX, Len(NumberX) - LongLong)) Else ReadNumber = ReadLongNumber(NumberX) End If If bFS = True Then ReadNumber = "负" & ReadNumber End If End Function Private Function ReadSmallNumber(SmallNumber As String) As String Dim i As Long For i = 1 To Len(SmallNumber) ReadSmallNumber = ReadSmallNumber & GetN(Mid(SmallNumber, i, 1)) Next i End Function Private Function ReadSmallNumberToRMB(SmallNumber As String) As String ReadSmallNumberToRMB = GetN(Mid(SmallNumber, 1, 1)) & "角" & GetN(Mid(SmallNumber, 2, 1)) & "分" End Function Public Function ReadNumberToRMB(ByVal NumberX As String) As String Dim LongX As String Dim PointX As String Dim LongLong As Long Dim bFS As Boolean '负数 If Not IsNumeric(NumberX) Then ReadNumberToRMB = "" Exit Function End If If CDbl(NumberX) < 0 Then NumberX = -NumberX bFS = True End If NumberX = CStr(Format(NumberX, "#.00")) LongLong = InStr(1, NumberX, ".") If Right(NumberX, Len(NumberX) - LongLong) <> "" Then ReadNumberToRMB = ReadLongNumber(Left(NumberX, LongLong - 1)) ReadNumberToRMB = ReadNumberToRMB & "元" & ReadSmallNumberToRMB(Right(NumberX, Len(NumberX) - LongLong)) Else ReadNumberToRMB = ReadLongNumber(NumberX) End If If bFS = True Then ReadNumberToRMB = "负" & ReadNumberToRMB End If End Function Private Sub Command1_Click() Text2.Text = ReadNumberToRMB(Text1.Text) Text3.Text = ReadNumber(Text1.Text) End Sub ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: vb
 输入关键字,在本站1000多万海量源码库中尽情搜索: