''功能:把数字总金额转换为大写金额
'Private Function AccountChang(ByRef strWan As String, ByRef strQian As String, ByRef strBai As String, ByRef strShi As String, _
'            ByRef strKuai As String, ByRef strJiao As String, ByRef strFen As String, ByVal strAccount As String)
'    Dim StrFPSum As String     
'    Dim intTemp(10)
'    Dim strLeft As String 
'    Dim strRight As String 
'    Dim strBLeft As String
'    Dim strBRight As String
'
'    '初始化
'    StrFPSum = ""
'    strAccount = Format(strAccount, "#########0.00")
'    intTemp(0) = "零": intTemp(1) = "壹": intTemp(2) = "贰": intTemp(3) = "叁": intTemp(4) = "肆"
'    intTemp(5) = "伍": intTemp(6) = "陆": intTemp(7) = "柒": intTemp(8) = "捌": intTemp(9) = "疚"
'
'    '取得小数点前后的字符串形式的数字
'    strLeft = Left(strAccount, InStr(strAccount, ".") - 1)
'    strRight = Mid(strAccount, Len(strAccount) - 1)
'
'    For i = 0 To Len(strRight) - 1
'        StrFPSum = intTemp(CInt(Mid(strRight, Len(strRight) - i, 1))) & StrFPSum
'    Next
'    StrFPSum = "." & StrFPSum
'    For i = 0 To Len(strLeft) - 1
'        StrFPSum = intTemp(CInt(Mid(strLeft, Len(strLeft) - i, 1))) & StrFPSum
'    Next
'
'    strBLeft = Left(StrFPSum, InStr(StrFPSum, ".") - 1)
'    strBRight = Mid(StrFPSum, Len(StrFPSum) - 1)
'
'On Error Resume Next
'    strFen = Mid(strBRight, 2, 1)
'    strJiao = Mid(strBRight, 1, 1)
'    strKuai = Mid(strBLeft, Len(strBLeft), 1)
'    strShi = Mid(strBLeft, Len(strBLeft) - 1, 1)
'    strBai = Mid(strBLeft, Len(strBLeft) - 2, 1)
'    strQian = Mid(strBLeft, Len(strBLeft) - 3, 1)
'    strWan = Mid(strBLeft, Len(strBLeft) - 4, 1)
'End Function我在外部调用这个函数
AccountChang Text1.Text, Text2.Text, Text3.Text, Text4.Text, Text5.Text, Text6.Text,Text7, Text8.Text
但是并没有在text1,text2...等中返回该返回的大写数字(text8.text为"13.23")
大家帮我调试一下看怎么解决这个问题我调试过,整个函数是没有错误的,就是在接口这个地方可能出现了问题。

解决方案 »

  1.   

    把 TextBox 的Text熟悉作为 ByRef 的参数并不能使调用的函数修改改属性,对于任何对象的任何属性都一样,对象的属性并不是一个简单变量,实际上是一个函数的返回值,VB 在调用时实际上是取TextBox的Text属性到一个中间变量中,然后用中间变量传递给函数,因此你的TextBox中的Text属性不会被改变,你只能这样调用:
    AccountChang str1, str2, str2 ...
    Text1.Text = str1
    Text2.Text = str2
    ...
      

  2.   

    不行,我用以下方法还是不行
    AccountChang strWans, strQians, strBais, strShis, strKuais, strJiaos, strFens, Text8.Text
      

  3.   

    '功能:把数字总金额转换为大写金额
    Private Function AccountChang(ByVal strWan As String, ByVal strQian As String, ByVal strBai As String, _
                                  ByVal strShi As String, _
              ByVal strKuai As String, ByVal strJiao As String, ByVal strFen As String, ByVal strAccount As String)
              
        Dim StrFPSum As String
        Dim intTemp(10)
        Dim strLeft As String
        Dim strRight As String
        Dim strBLeft As String
        Dim strBRight As String    '初始化
        StrFPSum = ""
        strAccount = Format(strAccount, "#########0.00")
        intTemp(0) = "零": intTemp(1) = "壹": intTemp(2) = "贰": intTemp(3) = "叁": intTemp(4) = "肆"
        intTemp(5) = "伍": intTemp(6) = "陆": intTemp(7) = "柒": intTemp(8) = "捌": intTemp(9) = "疚"    '取得小数点前后的字符串形式的数字
        strLeft = Left(strAccount, InStr(strAccount, ".") - 1)
        strRight = Mid(strAccount, Len(strAccount) - 1)    For i = 0 To Len(strRight) - 1
            StrFPSum = intTemp(CInt(Mid(strRight, Len(strRight) - i, 1))) & StrFPSum
        Next
        StrFPSum = "." & StrFPSum
        For i = 0 To Len(strLeft) - 1
            StrFPSum = intTemp(CInt(Mid(strLeft, Len(strLeft) - i, 1))) & StrFPSum
        Next    strBLeft = Left(StrFPSum, InStr(StrFPSum, ".") - 1)
        strBRight = Mid(StrFPSum, Len(StrFPSum) - 1)On Error Resume Next
        strFen = Mid(strBRight, 2, 1)
        strJiao = Mid(strBRight, 1, 1)
        strKuai = Mid(strBLeft, Len(strBLeft), 1)
        strShi = Mid(strBLeft, Len(strBLeft) - 1, 1)
        If Len(strBLeft) - 2 = 0 Then
           strBai = "零"
        Else
           strBai = Mid(strBLeft, Len(strBLeft) - 2, 1)
        End If
        If Len(strBLeft) - 2 = 0 Or Len(strBLeft) - 3 = 0 Then
           strQian = "零"
        Else
           strQian = Mid(strBLeft, Len(strBLeft) - 3, 1)
        End If
        If Len(strBLeft) - 2 = 0 Or Len(strBLeft) - 3 = 0 Or Len(strBLeft) - 4 = 0 Then
           strWan = "零"
        Else
           strWan = Mid(strBLeft, Len(strBLeft) - 4, 1)
        End If
        
        Text1.Text = strWan
        Text2.Text = strQian
        Text3.Text = strBai
        Text4.Text = strShi
        Text5.Text = strKuai
        Text6.Text = strJiao
        Text7.Text = strFen
    End Function