Public Function FilterInput(ByRef objInputBox As Object, _
                            ByVal intKeyAscii As Integer, _
                            Optional ByVal udtInputType As enumInputType = itNumeric, _
                            Optional ByVal strKeyCodeRange As String = "0-9", _
                            Optional ByVal blnSmallNumber As Boolean = False, _
                            Optional ByVal intMaxLength As Integer = 0, _
                            Optional ByVal blnShowMsg As Boolean = False _
                            ) As Integer
'************************************************************************
'*
'* ¹¦ÄÜ£ºÏÞÖÆÊäÈ룬¹ýÂË·Ç·¨×Ö·û/°´¼ü£¬Ö§³ÖÊý×Ö¡¢Îı¾¡¢ÈÕÆÚ¡¢Ê±¼ä¡¢ÓÊÕþ±àÂë¡¢Éí·ÝÖ¤µÈ¡£
'* ÊäÈ룺objInputBox           - ÊäÈë¶ÔÏó£¨Ö§³ÖTextBox¡¢ComboBoxµÈ£©
'*       intKeyAscii           - ÊäÈë×Ö·û/°´¼ü
'*       udtInputType(¿ÉÑ¡)    - ÊäÈëÀàÐÍ
'*       strKeyCodeRange(¿ÉÑ¡) - ÔÊÐí×Ö·û·¶Î§
'*       blnSmallNumber(¿ÉÑ¡)  - ÊÇ·ñÔÊÐíСÊýµã
'*       intMaxLength(¿ÉÑ¡)    - ÊäÈ볤¶È
'*       blnShowMsg(¿ÉÑ¡)      - ÊÇ·ñÏÔʾÌáʾ
'* ·µ»Ø£ºÈç¹ûÊäÈëΪºÏ·¨×Ö·û£¬Ö±½Ó·µ»Ø¸ÃÖµ£¬·´Ö®£¬·µ»Ø¿ÕÖµ(0)
'*
'* Ô¼¶¨£º·¶Î§·ûºÅΪ¡°-¡±£¬·Ö¸ô·ûºÅΪ¡°|¡±£¬ºÏ·¨Àý×Ó£º "a-z|.|0-9|,|A-Z|~"
'*
'* ×îºóÐ޸ģºUnruled Boy @ 1/12/2002
'*
'*************************************************************************    Dim o_strRet() As String
    Dim o_strText As String
    Dim o_strRange As String
    Dim o_intItems As Integer
    Dim o_intRet As Integer
    Dim o_intKeyAscii As Integer
    'Dim o_blnRet As Boolean
    Dim o_udtErrorType As enumErrorType
    
    o_udtErrorType = etDefault '³õʼ»¯´íÎó£ºÎÞ
        
    With objInputBox
        Select Case TypeName(objInputBox)
                Case "TextBox", "RichTextBox"
                    If .MaxLength > 0 Then 'Èç¹ûÓÐ×î´ó³¤¶ÈÏÞÖÆ£¬Ê¹ÓÃȱʡ
                        If intMaxLength = 0 Then
                            intMaxLength = .MaxLength
                        Else
                            If intMaxLength > .MaxLength Then
                                intMaxLength = .MaxLength
                            Else
                                
                            End If
                        End If
                    Else
                        
                    End If
                Case Else
                
        End Select
        
        o_strText = .Text
    
    End With

解决方案 »

  1.   

    '¿´Ä¿Ç°³¤¶ÈÊÇ·ñ³¬Ô½ÏÞÖƳ¤¶È£¬Èç¹ûÊÇ£¬Ìáʾ£¬ÊäÈëÎÞЧ
        If intMaxLength > 0 And Len(o_strText) >= intMaxLength Then
            
            Select Case intKeyAscii
                    Case vbKeyDelete, vbKeyBack 'ɾ³ýÓë»ØÍË
                        o_intKeyAscii = intKeyAscii
                    Case Else
                        Select Case TypeName(objInputBox)
                                Case "TextBox", "RichTextBox"
                                    If objInputBox.SelLength > 0 Then 'Èç¹ûÓÐÑ¡ÖÐÎı¾
                                        o_intKeyAscii = intKeyAscii
                                    Else
                                        Beep
                                        o_udtErrorType = etMaxLength
                                        o_intKeyAscii = 0
                                    End If
                                Case Else
                                    Beep
                                    o_udtErrorType = etMaxLength
                                    o_intKeyAscii = 0
                        End Select
            End Select
        Else
                    
      

  2.   

    'ÏÈ´¦ÀíÌØÊâ·ûºÅ
            Select Case intKeyAscii
                    Case vbKeyDelete, vbKeyBack 'ɾ³ýÓë»ØÍË
                        o_intKeyAscii = intKeyAscii
                                            
                    Case vbKeyDecimal, 190 'Êý×Ö£ºÐ¡Êýµã
                        If udtInputType = itNumeric And blnSmallNumber Then
                            o_intKeyAscii = intKeyAscii
                        Else
                            o_udtErrorType = etInvalid
                            o_intKeyAscii = 0
                        End If
                    
                    Case vbKeySubtract, vbKeyDivide, 45 'ÈÕÆÚ×Ö·û£º-¡¢/
                        If udtInputType = itDate Then
                            o_intKeyAscii = intKeyAscii
                        ElseIf udtInputType = itNumeric Then
                            If Len(o_strText) = 0 Then
                                o_intKeyAscii = intKeyAscii
                            Else
                                o_udtErrorType = etInvalid
                                o_intKeyAscii = 0
                            End If
                        Else
                            o_udtErrorType = etInvalid
                            o_intKeyAscii = 0
                        End If
                        
                    Case Asc(":") 'ʱ¼ä×Ö·û£º:
                        If udtInputType = itTime Then
                            o_intKeyAscii = intKeyAscii
                        Else
                            o_udtErrorType = etInvalid
                            o_intKeyAscii = 0
                        End If
                    
                    Case Else
                    
                        'o_blnRet = False
                        
                        o_strRange = strKeyCodeRange
                        
                        If o_strRange <> vbNullString Then
                            
                            o_intItems = 0
                            
                            '&Ntilde;&shy;&raquo;·&Egrave;&yen;&micro;&ocirc;×ó±&szlig;&ordm;&Iacute;&Oacute;&Ograve;±&szlig;&micro;&Auml;·&Ouml;&cedil;&ocirc;·&ucirc;&ordm;&Aring;&pound;¨"|"&pound;&copy;
                            Do While o_intItems < Len(o_strRange)
                                If Left(o_strRange, 1) = "|" Then
                                    o_strRange = Right(o_strRange, _
                                                        Len(o_strRange) - 1)
                                ElseIf Right(o_strRange, 1) = "|" Then
                                    o_strRange = Left(o_strRange, _
                                                        Len(o_strRange) - 1)
                                Else
                                End If
                                
                                o_intItems = o_intItems + 1
                            Loop
                            
                            '&frac12;&acirc;&Ecirc;&Iacute;×é&ordm;&Iuml;&sup2;&Icirc;&Ecirc;&yacute;
                            o_strRet() = Split(o_strRange, "|")
                            For o_intItems = LBound(o_strRet) To UBound(o_strRet)
                                o_intRet = InStr(o_strRet(o_intItems), "-")
                                If o_intRet <> 0 Then
                                    If intKeyAscii >= Asc(Left(o_strRet(o_intItems), o_intRet - 1)) _
                                            And intKeyAscii <= Asc(Right(o_strRet(o_intItems), Len(o_strRet(o_intItems)) - o_intRet)) Then
                                        o_intKeyAscii = intKeyAscii
                                        Exit For
                                    End If
                                Else
                                    If intKeyAscii = Val(o_strRet(o_intItems)) Then
                                        'o_blnRet = True
                                        o_intKeyAscii = intKeyAscii
                                        Exit For
                                    Else
                                    End If
                                End If
                            Next
                            
                            If o_intKeyAscii = 0 Then
                                o_udtErrorType = etRange
                            Else
                            End If
                            
                        Else
                            o_intKeyAscii = intKeyAscii
                        End If        End Select
                        
        End If
      

  3.   

    If o_udtErrorType <> etDefault Then '&Egrave;&ccedil;&sup1;&ucirc;&frac12;á&sup1;&ucirc;&Oacute;&ETH;&acute;í&pound;&not;&cedil;ù&frac34;&Yacute;&acute;í&Icirc;ó&Agrave;à&ETH;&Iacute;&pound;&not;&Igrave;á&Ecirc;&frac34;
        
            If blnShowMsg Then
                Select Case o_udtErrorType
                        Case etRange
                            MsgBox "&Ecirc;&auml;&Egrave;&euml;&micro;&Auml;[·&para;&Icirc;§]&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & _
                                    "&ordm;&Iuml;·¨&micro;&Auml;&Ecirc;&auml;&Egrave;&euml;·&para;&Icirc;§&Icirc;&ordf;&pound;&ordm;" & _
                                    Replace(o_strRange, "|", "&pound;&not;") & "&iexcl;&pound;", _
                                    vbInformation
                        Case etMaxLength
                            MsgBox "&Ecirc;&auml;&Egrave;&euml;&micro;&Auml;[&sup3;¤&para;&Egrave;]&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & _
                                    "&Ograve;&ordf;&Ccedil;ó&Ecirc;&auml;&Egrave;&euml;×&icirc;&acute;ó&sup3;¤&para;&Egrave;&Icirc;&ordf;&pound;&ordm; " & _
                                    CStr(intMaxLength), vbInformation
                        Case etInvalid
                            MsgBox "&Ecirc;&auml;&Egrave;&euml;×&Ouml;·&ucirc;&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&pound;&not;&Ccedil;&euml;&frac14;ì&sup2;é&Auml;ú&micro;&Auml;&Ecirc;&auml;&Egrave;&euml;&Ecirc;&Ccedil;·&ntilde;&ordm;&Iuml;·¨&iexcl;&pound;" & _
                                    "&Igrave;á&Ecirc;&frac34;&pound;&ordm;&ordm;&Iuml;·¨&micro;&Auml;&Ecirc;&auml;&Egrave;&euml;·&para;&Icirc;§&Icirc;&ordf;&pound;&ordm;" & _
                                    Replace(o_strRange, "|", "&pound;&not;") & "&iexcl;&pound;", _
                                    vbInformation
                        Case Else
                            
                End Select
                
            Else
            
            End If
        Else
            
        End If
        
        FilterInput = o_intKeyAscii
        
        Exit Function
        
        
    handleError:
        FilterInput = 0
        If blnShowMsg Then
            MsgBox "&Ocirc;&Uacute;&sup1;&yacute;&Acirc;&Euml;&micro;&Auml;&sup1;&yacute;&sup3;&Igrave;&Ouml;&ETH;&sup3;&ouml;&Iuml;&Ouml;&Ograve;&Ocirc;&Iuml;&Acirc;&acute;í&Icirc;ó&pound;&ordm;" & vbCrLf _
                     & Err.Description
        Else
        End If
        On Error GoTo 0
            
    End Function
      

  4.   

    以上是主函数(输入过滤)代码比较长,请原谅。Public Function ValidateNumber(ByRef objInputBox As Object, _
                                  ByVal curMinNum As Currency, _
                                  ByVal curMaxNum As Currency, _
                                  Optional ByVal intMaxLength As Integer = 0, _
                                  Optional ByVal blnCanBeEmpty As Boolean = False, _
                                  Optional ByVal blnShowMsg As Boolean = False _
                                  ) As enumErrorType
    '********************************************
    '*
    '* &sup1;&brvbar;&Auml;&Uuml;&pound;&ordm;&ETH;&pound;&Ntilde;é&Ecirc;&auml;&Egrave;&euml;&pound;¨&Ecirc;&yacute;×&Ouml;&pound;&copy;
    '* &Ecirc;&auml;&Egrave;&euml;&pound;&ordm;objInputBox        - &Ecirc;&auml;&Egrave;&euml;&para;&Ocirc;&Iuml;ó&pound;¨&Ouml;§&sup3;&Ouml;TextBox&iexcl;&cent;ComboBox&micro;&Egrave;&pound;&copy;
    '*       curMinNum          - &Ocirc;&Ecirc;&ETH;í×&icirc;&ETH;&iexcl;&Ouml;&micro;
    '*       curMaxNum          - &Ocirc;&Ecirc;&ETH;í×&icirc;&acute;ó&Ouml;&micro;
    '*       intMaxLength(&iquest;&Eacute;&Ntilde;&iexcl;) - &Ecirc;&auml;&Egrave;&euml;&sup3;¤&para;&Egrave;
    '*       blnCanBeEmpty(&iquest;&Eacute;&Ntilde;&iexcl;)- &Ecirc;&Ccedil;·&ntilde;&Ocirc;&Ecirc;&ETH;í&iquest;&Otilde;&Ouml;&micro;
    '*       blnShowMsg(&iquest;&Eacute;&Ntilde;&iexcl;)   - &Ecirc;&Ccedil;·&ntilde;&Iuml;&Ocirc;&Ecirc;&frac34;&Igrave;á&Ecirc;&frac34;
    '* ·&micro;&raquo;&Oslash;&pound;&ordm;&Egrave;&ccedil;&sup1;&ucirc;&Ecirc;&auml;&Egrave;&euml;&Ouml;&micro;&ordm;&Iuml;·¨&pound;&not;·&micro;&raquo;&Oslash;True&pound;&not;·&acute;&Ouml;&reg;&pound;&not;False
    '*
    '* ×&icirc;&ordm;ó&ETH;&THORN;&cedil;&Auml;&pound;&ordm;Unruled Boy @ 1/11/2002
    '*
    '********************************************
        
    On Error GoTo handleError
        
        Dim o_strText As String
        Dim o_lngNumber As Currency
        Dim o_udtErrorType As enumErrorType
        
        o_udtErrorType = etDefault '&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;&acute;í&Icirc;ó&pound;&ordm;&Icirc;&THORN;
                
        With objInputBox
            
            Select Case TypeName(objInputBox)
                    Case "TextBox", "RichTextBox"
                        If .MaxLength > 0 Then '&Egrave;&ccedil;&sup1;&ucirc;&Oacute;&ETH;×&icirc;&acute;ó&sup3;¤&para;&Egrave;&Iuml;&THORN;&Ouml;&AElig;&pound;&not;&Ecirc;&sup1;&Oacute;&Atilde;&Egrave;±&Ecirc;&iexcl;
                            If intMaxLength = 0 Then
                                intMaxLength = .MaxLength
                            Else
                                If intMaxLength > .MaxLength Then
                                    intMaxLength = .MaxLength
                                Else
                                    
                                End If
                            End If
                        Else
                            
                        End If
                    Case Else
                    
            End Select
            
            o_strText = .Text
            
            '&iquest;&acute;&Auml;&iquest;&Ccedil;°&sup3;¤&para;&Egrave;&Ecirc;&Ccedil;·&ntilde;&sup3;&not;&Ocirc;&frac12;&Iuml;&THORN;&Ouml;&AElig;&sup3;¤&para;&Egrave;&pound;&not;&Egrave;&ccedil;&sup1;&ucirc;&Ecirc;&Ccedil;&pound;&not;&Igrave;á&Ecirc;&frac34;&pound;&not;&Ecirc;&auml;&Egrave;&euml;&Icirc;&THORN;&ETH;§
            If intMaxLength > 0 And Len(o_strText) > intMaxLength Then
                
                o_udtErrorType = etMaxLength
                
            Else
                If o_strText <> vbNullString Then
                    If IsNumeric(o_strText) Then
                        o_lngNumber = CCur(o_strText)
                        If o_lngNumber < curMinNum Or o_lngNumber > curMaxNum Then
                            On Error Resume Next
                            .SetFocus
                            On Error GoTo 0
                            o_udtErrorType = etRange
                        Else
                            o_udtErrorType = etDefault
                        End If
                    Else
                        o_udtErrorType = etInvalid
                    End If
                Else
                    If Not blnCanBeEmpty Then
                        o_udtErrorType = etEmpty
                    Else
                    
                    End If
                End If
            End If
        
            If o_udtErrorType <> etDefault Then '&Egrave;&ccedil;&sup1;&ucirc;&frac12;á&sup1;&ucirc;&Oacute;&ETH;&acute;í&pound;&not;&cedil;ù&frac34;&Yacute;&acute;í&Icirc;ó&Agrave;à&ETH;&Iacute;&pound;&not;&Igrave;á&Ecirc;&frac34;
                On Error Resume Next
                .SetFocus
                On Error GoTo 0
                
                If blnShowMsg Then
                    Select Case o_udtErrorType
                            Case etRange
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&Ouml;&micro;[·&para;&Icirc;§]&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & vbCrLf & _
                                        "&Ograve;&ordf;&Ccedil;ó&Ecirc;&auml;&Egrave;&euml;·&para;&Icirc;§&Icirc;&ordf;&pound;&ordm; " & curMinNum & _
                                        " &micro;&frac12; " & curMaxNum, vbInformation
                            Case etMaxLength
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&Ouml;&micro;[&sup3;¤&para;&Egrave;]&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & _
                                        "&Ograve;&ordf;&Ccedil;ó&Ecirc;&auml;&Egrave;&euml;&sup3;¤&para;&Egrave;&Icirc;&ordf;&pound;&ordm; " & _
                                        CStr(intMaxLength), vbInformation
                            Case etInvalid
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&Ograve;&ordf;&Ccedil;ó&Egrave;&laquo;&sup2;&iquest;&Icirc;&ordf;&Ecirc;&yacute;×&Ouml;(°ü&Agrave;¨&iexcl;°.&iexcl;±)&iexcl;&pound;" & vbCrLf & _
                                        "&Ccedil;&euml;&frac14;ì&sup2;é&Ecirc;&auml;&Egrave;&euml;&micro;&Auml;&Ecirc;&Ccedil;·&ntilde;&Oacute;&ETH;·&Ccedil;&Ecirc;&yacute;×&Ouml;·&ucirc;&ordm;&Aring;&iexcl;&pound;" _
                                        , vbInformation
                            Case etEmpty
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&sup2;&raquo;&Auml;&Uuml;&Icirc;&ordf;&iquest;&Otilde;&Ouml;&micro;&iexcl;&pound;" & vbCrLf & _
                                        "&Auml;ú±&Oslash;&ETH;&euml;°&acute;&Ograve;&ordf;&Ccedil;ó&Ecirc;&auml;&Egrave;&euml;&Ecirc;&yacute;×&Ouml;" _
                                        , vbInformation
                            Case Else
                                
                    End Select
                Else
                    
                End If
            Else
                
            End If
            
        End With
            
        ValidateNumber = o_udtErrorType
        
        Exit Function
        
        
    handleError:
        ValidateNumber = etUnknown
        If blnShowMsg Then
            MsgBox "&Ocirc;&Uacute;&ETH;&pound;&Ntilde;é&Ecirc;&yacute;×&Ouml;&micro;&Auml;&sup1;&yacute;&sup3;&Igrave;&Ouml;&ETH;&sup3;&ouml;&Iuml;&Ouml;&Ograve;&Ocirc;&Iuml;&Acirc;&acute;í&Icirc;ó&pound;&ordm;" & vbCrLf _
                     & Err.Description
        Else
        End If
        On Error GoTo 0
        
    End Function
      

  5.   


    Public Function ValidateText(ByRef objInputBox As Object, _
                                  ByVal strForbiddenChars As String, _
                                  Optional ByVal strSplitChar As String = "|", _
                                  Optional ByVal strReplaceChar As String = vbNullString, _
                                  Optional ByVal blnAuthReplace As Boolean = False, _
                                  Optional ByVal intMaxLength As Integer = 0, _
                                  Optional ByVal blnCanBeEmpty As Boolean = False, _
                                  Optional ByVal blnShowMsg As Boolean = False _
                                  ) As enumErrorType
    '********************************************
    '*
    '* &sup1;&brvbar;&Auml;&Uuml;&pound;&ordm;&ETH;&pound;&Ntilde;é&Ecirc;&auml;&Egrave;&euml;&pound;¨×&Ouml;·&ucirc;&pound;&copy;
    '* &Ecirc;&auml;&Egrave;&euml;&pound;&ordm;objInputBox          - &Ecirc;&auml;&Egrave;&euml;&para;&Ocirc;&Iuml;ó&pound;¨&Ouml;§&sup3;&Ouml;TextBox&iexcl;&cent;ComboBox&micro;&Egrave;&pound;&copy;
    '*       strForbiddenChars    - &Ocirc;&Ecirc;&ETH;í×&icirc;&acute;ó&Ouml;&micro;
    '*       strSplitChar&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;   - ·&Ouml;&cedil;&icirc;×&Ouml;·&ucirc;
    '*       strReplaceChar(&iquest;&Eacute;&Ntilde;&iexcl;) - &Igrave;&aelig;&raquo;&raquo;×&Ouml;·&ucirc;
    '*       blnAuthReplace(&iquest;&Eacute;&Ntilde;&iexcl;) - &Ecirc;&Ccedil;·&ntilde;×&Ocirc;&para;&macr;&Igrave;&aelig;&raquo;&raquo;×&Ouml;·&ucirc;
    '*       intMaxLength(&iquest;&Eacute;&Ntilde;&iexcl;)   - &Ecirc;&auml;&Egrave;&euml;&sup3;¤&para;&Egrave;
    '*       blnCanBeEmpty(&iquest;&Eacute;&Ntilde;&iexcl;)  - &Ecirc;&Ccedil;·&ntilde;&Ocirc;&Ecirc;&ETH;í&iquest;&Otilde;&Ouml;&micro;
    '*       blnShowMsg(&iquest;&Eacute;&Ntilde;&iexcl;)     - &Ecirc;&Ccedil;·&ntilde;&Iuml;&Ocirc;&Ecirc;&frac34;&Igrave;á&Ecirc;&frac34;
    '*
    '* ·&micro;&raquo;&Oslash;&pound;&ordm;&Egrave;&ccedil;&sup1;&ucirc;&Ecirc;&auml;&Egrave;&euml;&Ouml;&micro;&ordm;&Iuml;·¨&pound;&not;·&micro;&raquo;&Oslash;True&pound;&not;·&acute;&Ouml;&reg;&pound;&not;False
    '*
    '* ×&icirc;&ordm;ó&ETH;&THORN;&cedil;&Auml;&pound;&ordm;Unruled Boy @ 1/11/2002
    '*
    '********************************************
            
    On Error GoTo handleError
        
        Dim o_strRet() As String
        Dim o_strText As String
        Dim o_intItems As Integer
        Dim o_intItems2 As Integer
        Dim o_intPos As Integer
        Dim o_intPos2 As Integer
        Dim o_intLen As Integer
        Dim o_udtErrorType As enumErrorType
        
        o_udtErrorType = etDefault '&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;&acute;í&Icirc;ó&pound;&ordm;&Icirc;&THORN;
        
        With objInputBox
            
            Select Case TypeName(objInputBox)
                    Case "TextBox", "RichTextBox"
                        If .MaxLength > 0 Then '&Egrave;&ccedil;&sup1;&ucirc;&Oacute;&ETH;×&icirc;&acute;ó&sup3;¤&para;&Egrave;&Iuml;&THORN;&Ouml;&AElig;&pound;&not;&Ecirc;&sup1;&Oacute;&Atilde;&Egrave;±&Ecirc;&iexcl;
                            If intMaxLength = 0 Then
                                intMaxLength = .MaxLength
                            Else
                                If intMaxLength > .MaxLength Then
                                    intMaxLength = .MaxLength
                                Else
                                    
                                End If
                            End If
                        Else
                            
                        End If
                    Case Else
                    
            End Select
            
            o_strText = .Text
        
            
            '&iquest;&acute;&Auml;&iquest;&Ccedil;°&sup3;¤&para;&Egrave;&Ecirc;&Ccedil;·&ntilde;&sup3;&not;&Ocirc;&frac12;&Iuml;&THORN;&Ouml;&AElig;&sup3;¤&para;&Egrave;&pound;&not;&Egrave;&ccedil;&sup1;&ucirc;&Ecirc;&Ccedil;&pound;&not;&Igrave;á&Ecirc;&frac34;&pound;&not;&Ecirc;&auml;&Egrave;&euml;&Icirc;&THORN;&ETH;§
            If intMaxLength > 0 And Len(o_strText) > intMaxLength Then
                
                o_udtErrorType = etMaxLength
                
            Else
                
                If o_strText <> vbNullString And strForbiddenChars <> vbNullString Then
                
                    o_intItems2 = 0
                    
                    o_intPos2 = Len(o_strText)
                    o_intLen = 0
                    
                    o_strRet() = Split(strForbiddenChars, strSplitChar)
                    
                    For o_intItems = LBound(o_strRet) To UBound(o_strRet)
                        o_intPos = InStr(o_strText, o_strRet(o_intItems))
                        If o_intPos > 0 And o_intPos < o_intPos2 Then '&micro;&Uacute;&Ograve;&raquo;&cedil;&ouml;&sup3;&ouml;&Iuml;&Ouml;&Icirc;&raquo;&Ouml;&Atilde;
                            o_intPos2 = o_intPos
                            o_intLen = Len(o_strRet(o_intItems))
                        End If
                        
                        If o_intPos <> 0 Then
                            
                            If blnAuthReplace Then
                               o_strText = Replace(o_strText, _
                                                    o_strRet(o_intItems), _
                                                    strReplaceChar)
                               o_udtErrorType = etModified
                            Else
                                o_udtErrorType = etInvalid
                            End If
                        Else
                            o_intItems2 = o_intItems2 + 1
                        End If
                    Next
                                
                    If blnAuthReplace Then
                        .Text = o_strText
                    Else
                        .SelStart = o_intPos2 - 1
                        .SelLength = o_intLen
                    End If
                                
                    If o_intItems2 > UBound(o_strRet) Then
                        o_udtErrorType = etDefault
                    Else
                    
                    End If
                    
                Else
                    If Not blnCanBeEmpty Then
                        o_udtErrorType = etEmpty
                    Else
                    
                    End If
                End If
            End If
        
      

  6.   

    If o_udtErrorType <> etDefault Then '&Egrave;&ccedil;&sup1;&ucirc;&frac12;á&sup1;&ucirc;&Oacute;&ETH;&acute;í&pound;&not;&cedil;ù&frac34;&Yacute;&acute;í&Icirc;ó&Agrave;à&ETH;&Iacute;&pound;&not;&Igrave;á&Ecirc;&frac34;
                On Error Resume Next
                .SetFocus
                On Error GoTo 0
                        
                If blnShowMsg Then
                    Select Case o_udtErrorType
                            Case etInvalid
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & vbCrLf & _
                                        "&Ograve;&Ocirc;&Iuml;&Acirc;×&Ouml;·&ucirc;&sup2;&raquo;&Auml;&Uuml;&acute;&aelig;&Ocirc;&Uacute;&pound;&ordm; " & vbCrLf & _
                                        Join(o_strRet, "&pound;&not;") & "&iexcl;&pound;" _
                                        , vbInformation
                            Case etModified
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & vbCrLf & _
                                        "&Ograve;&Ocirc;&Iuml;&Acirc;×&Ouml;·&ucirc;&sup2;&raquo;&Auml;&Uuml;&acute;&aelig;&Ocirc;&Uacute;&pound;&ordm; " & _
                                        Join(o_strRet, "&pound;&not;") & "&iexcl;&pound;" & vbCrLf & _
                                        IIf(blnAuthReplace, vbCrLf & _
                                           "&cedil;&Atilde;×&Ouml;·&ucirc;&Ograve;&Ntilde;&frac34;&shy;±&raquo;×&Ocirc;&para;&macr;&cedil;ü&Otilde;&yacute;&iexcl;&pound;", vbNullString) _
                                        , vbInformation
                            Case etEmpty
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & vbCrLf & _
                                        "&sup2;&raquo;&Auml;&Uuml;&Icirc;&ordf;&iquest;&Otilde;&pound;&not;&Auml;ú±&Oslash;&ETH;&euml;°&acute;&Ograve;&ordf;&Ccedil;ó&Ecirc;&auml;&Egrave;&euml;&Icirc;&Auml;×&Ouml;&iexcl;&pound;" _
                                        , vbInformation
                    End Select
                Else
                    
                End If
            Else
            
            End If
        
        End With
        
        ValidateText = o_udtErrorType
        
        Exit Function
        
        
    handleError:
        ValidateText = etUnknown
        If blnShowMsg Then
            MsgBox "&Ocirc;&Uacute;&ETH;&pound;&Ntilde;é&Icirc;&Auml;±&frac34;&micro;&Auml;&sup1;&yacute;&sup3;&Igrave;&Ouml;&ETH;&sup3;&ouml;&Iuml;&Ouml;&Ograve;&Ocirc;&Iuml;&Acirc;&acute;í&Icirc;ó&pound;&ordm;" & vbCrLf _
                    & Err.Description
        Else
        End If
        On Error GoTo 0
        
    End Function
      

  7.   


    Public Function ValidatePostCode(ByRef objInputBox As Object, _
                                  Optional ByVal blnCanBeEmpty As Boolean = False, _
                                  Optional ByVal blnShowMsg As Boolean = False _
                                  ) As enumErrorType
    '********************************************
    '*
    '* &sup1;&brvbar;&Auml;&Uuml;&pound;&ordm;&ETH;&pound;&Ntilde;é&Ecirc;&auml;&Egrave;&euml;&pound;¨&Oacute;&Ecirc;&Otilde;&thorn;±à&Acirc;&euml;&pound;&copy;
    '* &Ecirc;&auml;&Egrave;&euml;&pound;&ordm;objInputBox          - &Ecirc;&auml;&Egrave;&euml;&para;&Ocirc;&Iuml;ó&pound;¨&Ouml;§&sup3;&Ouml;TextBox&iexcl;&cent;ComboBox&micro;&Egrave;&pound;&copy;
    '*       blnCanBeEmpty(&iquest;&Eacute;&Ntilde;&iexcl;)  - &Ecirc;&Ccedil;·&ntilde;&Ocirc;&Ecirc;&ETH;í&iquest;&Otilde;&Ouml;&micro;
    '*       blnShowMsg(&iquest;&Eacute;&Ntilde;&iexcl;)     - &Ecirc;&Ccedil;·&ntilde;&Iuml;&Ocirc;&Ecirc;&frac34;&Igrave;á&Ecirc;&frac34;
    '*
    '* ·&micro;&raquo;&Oslash;&pound;&ordm;&Egrave;&ccedil;&sup1;&ucirc;&Ecirc;&auml;&Egrave;&euml;&Ouml;&micro;&ordm;&Iuml;·¨&pound;&not;·&micro;&raquo;&Oslash;True&pound;&not;·&acute;&Ouml;&reg;&pound;&not;False
    '*
    '* ×&icirc;&ordm;ó&ETH;&THORN;&cedil;&Auml;&pound;&ordm;Unruled Boy @ 1/13/2002
    '*
    '********************************************
            
    On Error GoTo handleError    Dim o_strText As String
        Dim o_udtErrorType As enumErrorType
        
        o_udtErrorType = etDefault '&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;&acute;í&Icirc;ó&pound;&ordm;&Icirc;&THORN;
        
        With objInputBox
            
            o_strText = .Text
                
            '&iquest;&acute;&Auml;&iquest;&Ccedil;°&sup3;¤&para;&Egrave;&Ecirc;&Ccedil;·&ntilde;&sup3;&not;&Ocirc;&frac12;&Iuml;&THORN;&Ouml;&AElig;&sup3;¤&para;&Egrave;&pound;&not;&Egrave;&ccedil;&sup1;&ucirc;&Ecirc;&Ccedil;&pound;&not;&Igrave;á&Ecirc;&frac34;&pound;&not;&Ecirc;&auml;&Egrave;&euml;&Icirc;&THORN;&ETH;§
            If Len(o_strText) > mc_intPostCodeLength Then
                
                o_udtErrorType = etMaxLength
                
            Else
                
                If o_strText <> vbNullString Then
                    
                    If IsNumeric(o_strText) Then
                        
                        If Len(o_strText) = mc_intPostCodeLength Then
                            '
                            '
                            '
                            o_udtErrorType = etDefault
                        Else
                            o_udtErrorType = etInvalid
                        End If
                        
                    Else
                        o_udtErrorType = etRange
                    End If
                    
                Else
                    If Not blnCanBeEmpty Then
                        o_udtErrorType = etEmpty
                    Else
                    
                    End If
                End If
            End If
                    
            If o_udtErrorType <> etDefault Then '&Egrave;&ccedil;&sup1;&ucirc;&frac12;á&sup1;&ucirc;&Oacute;&ETH;&acute;í&pound;&not;&cedil;ù&frac34;&Yacute;&acute;í&Icirc;ó&Agrave;à&ETH;&Iacute;&pound;&not;&Igrave;á&Ecirc;&frac34;
                On Error Resume Next
                .SetFocus
                On Error GoTo 0
                        
                If blnShowMsg Then
                    Select Case o_udtErrorType
                            Case etRange
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&Ouml;&micro;[·&para;&Icirc;§]&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & vbCrLf & _
                                        "&Oacute;&Ecirc;&Otilde;&thorn;±à&Acirc;&euml;&Ograve;&ordf;&Ccedil;ó&Egrave;&laquo;&sup2;&iquest;&Icirc;&ordf;&Ecirc;&yacute;×&Ouml;&iexcl;&pound; " _
                                        , vbInformation
                            Case etMaxLength
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&Ouml;&micro;[&sup3;¤&para;&Egrave;]&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & _
                                        "&Ograve;&ordf;&Ccedil;ó&Ecirc;&auml;&Egrave;&euml;&sup3;¤&para;&Egrave;&Icirc;&ordf;&pound;&ordm; " & _
                                        CStr(mc_intPostCodeLength), vbInformation
                            Case etInvalid
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&micro;&Auml;&Oacute;&Ecirc;&Otilde;&thorn;±à&Acirc;&euml;&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & vbCrLf & _
                                        "&Igrave;á&Ecirc;&frac34;&pound;&ordm;&Oacute;&Ecirc;&Otilde;&thorn;±à&Acirc;&euml;±&Oslash;&ETH;&euml;&Egrave;&laquo;&sup2;&iquest;&Icirc;&ordf;&Ecirc;&yacute;×&Ouml;&pound;&not;" & _
                                        "&para;&oslash;&Ccedil;&Ograve;&sup3;¤&para;&Egrave;±&Oslash;&ETH;&euml;&Icirc;&ordf;" & _
                                        CStr(mc_intPostCodeLength) & "&Icirc;&raquo;&iexcl;&pound;&iexcl;&pound;" _
                                        , vbInformation
                            Case etEmpty
                                MsgBox "&Ecirc;&auml;&Egrave;&euml;&sup2;&raquo;·&ucirc;&ordm;&Iuml;&Ograve;&ordf;&Ccedil;ó&iexcl;&pound;" & vbCrLf & _
                                        "&Oacute;&Ecirc;&Otilde;&thorn;±à&Acirc;&euml;&sup2;&raquo;&Auml;&Uuml;&Icirc;&ordf;&iquest;&Otilde;&pound;&not;&Auml;ú±&Oslash;&ETH;&euml;°&acute;&Ograve;&ordf;&Ccedil;ó&Ecirc;&auml;&Egrave;&euml;&iexcl;&pound;" _
                                        , vbInformation
                    End Select
                Else
                    
                End If
            Else
            
            End If
        
        End With
        
        ValidatePostCode = o_udtErrorType
        
        Exit Function
        
        
    handleError:
        ValidatePostCode = etUnknown
        If blnShowMsg Then
            MsgBox "&Ocirc;&Uacute;&ETH;&pound;&Ntilde;é&Oacute;&Ecirc;&Otilde;&thorn;±à&Acirc;&euml;&micro;&Auml;&sup1;&yacute;&sup3;&Igrave;&Ouml;&ETH;&sup3;&ouml;&Iuml;&Ouml;&Ograve;&Ocirc;&Iuml;&Acirc;&acute;í&Icirc;ó&pound;&ordm;" & vbCrLf _
                    & Err.Description
        Else
        End If
        On Error GoTo 0
        
    End Function
      

  8.   

    to:enmity (灵感之源) 
    你可以把代码发到-文档中心-
      

  9.   

    to:jiangtao(蒋涛) 呵呵,这个我倒是忘记了,谢谢你吖,社长:)
      

  10.   

    对,我也觉得不大妥当,粘贴出来的中文全部变成(Encode过的)乱码了。
      

  11.   

    这个和XML的处理有关,我们正在检查代码
      

  12.   

    不要用这种编码方式,在xml中& 是不允许出现的。
      

  13.   

    to:ghj1976(蝈蝈俊.net) 呵呵,我原来是中文的啊!现在就变成这样了 :(还有,我不能在文档中心发布文章阿,每次都等老半天,然后就是“网页没有找到”......
      

  14.   

    估计是从unicode贴过来的,可以试试看保存到一个html文件,然后用IE打开,用正确的编码方式浏览,然后ctrl-a选中,保存到notepad这样不支持HTML的OLE和自动编码的编辑器,保存成html。
    呵呵,虽然麻烦点,没有转码工具的时候用来在big5/unicode/gb之间转码也倒有效。好长啊,enmity ...
    不如upload倒某个地方然后贴url咯 :)
      

  15.   

    to:joyplay(想吃老虎的小猪) 其实我早就upload到:http://caotang.mytang.com/temp/smartflexinput.zip可是,很多网友都说下载不了阿!
      

  16.   

    enmity(灵感之源) :
    你提供的这个网址,不知怎么回事,FlashGet总是下的不对(100多K,打不开),但其他都好的,包括蚂蚁,ie直接下都可以,可能FlashGet有Bug
      

  17.   

    to:fuxc(Michael) 呵呵,我有些时候也这样,或许是网站本身的问题吧。