Public Function je(ByVal szje As Double) As String
创新互联是专业的温州网站建设公司,温州接单;提供成都网站建设、做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行温州网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
Dim s As String = ""
Dim sz() As String = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}
Dim dw() As String = {"圆", "拾", "佰", "千", "万", "拾", "佰", "仟", "拾", "佰", "仟"}
If szje 0 Then
s = "负"
szje = Math.Abs(szje)
End If
Dim zh() As String = Split(Str(szje), ".")
If zh.Length 2 Then
Return "ERROR:格式错"
Exit Function
End If
zh(0) = Trim(zh(0))
zh(1) = Trim(zh(1))
Dim i As Integer
For i = 1 To Len(zh(0))
s = s sz(Val(Mid(zh(0), i, 1))) dw(Len(zh(0)) - i)
Next
For i = 1 To Len(zh(1))
s = s sz(Val(Mid(zh(1), i, 1))) Choose(i, "角", "分", "厘", "毫")
Next
s = s "整"
Return s
End Function
Private Sub Text2_Change() '大写金额转换成阿拉伯数字金额
Dim i As Integer
Dim j As Integer
Dim myint As Integer
Dim myint1 As Integer
Dim mydoub As Double
Dim mystr As String
Dim mystr1 As String
Dim mystr2 As String
Dim mystr3 As String
Dim mystr4 As String
Dim money As Long
Dim money1 As Integer
Dim money2 As Long
mystr = Text2.Text
myint = InStr(mystr, ".")
If myint = 0 Then
mystr = Text2.Text
Else
mystr3 = Right(Text2.Text, Len(Text2.Text) - myint)
If mystr3 "" Then '转换小数位
mystr4 = Left(mystr3, 1)
mystr3 = Right(mystr3, Len(mystr3) - 1)
If mystr4 "0" Then
mystr2 = mystr2 + setdata(Val(mystr4)) + "角"
End If
If mystr3 "" Then
mystr4 = Left(mystr3, 1)
mystr2 = mystr2 + setdata(Val(mystr4)) + "分"
End If
End If
mystr = Left(Text2.Text, myint - 1)
End If
j = Len(mystr)
For i = 1 To Len(mystr) '转换整数位
money2 = Left(mystr, i)
money1 = Right(money2, 1)
If money1 = 0 Then
If j = 5 Then
If Right(mystr1, 1) "万" Then mystr1 = mystr1 "万"
Else
If Right(mystr1, 1) "零" And Right(money, j) 0 Then mystr1 = mystr1 "零"
End If
Else
mystr1 = mystr1 setdata(money1) + chang(j)
End If
j = j - 1
Next i
Text1.Text = mystr1 "元" mystr2 '显示大写
End Sub
可以试着用典型的VB字符串函数UCase解决。
比如先把输入的内容放到字符串A$中,若A$="a",则经
A$=UCase(A$)转换后,结果即是A$="A"。
我在程序中是这麽处理的。行不行,试试就知道了。