标题:求高手讲解下这段大小写转换的代码 帮忙写上注释通俗易懂点 我没齿难忘
取消只看楼主
a13582220882
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2013-9-20
结帖率:0
 问题点数:0 回复次数:0 
求高手讲解下这段大小写转换的代码 帮忙写上注释通俗易懂点 我没齿难忘
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)) + "角"
            Else
                mystr2 = mystr2 + "零"
            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 = Left(mystr1, Len(mystr1) - 1)
                If Right(mystr1, 1) <> "万" Then mystr1 = mystr1 & "万"
            Else
                If Right(mystr1, 1) <> "零" And Right(mystr, 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
搜索更多相关主题的帖子: money 
2014-03-31 18:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-429464-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.258510 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved