如题,在线等,谢谢各位大侠帮忙。

解决方案 »

  1.   

    '
    '只允许输入数字
    '函数:InNum
    '参数:KeyCode ASCII码.LeachCode 自定义过滤字符串.
    '返回值:无
    '注:一般应用于KEYDOWN事件中.
    Public Function InNum(ByRef SourVal As String, ByRef KeyAscii As Integer)
            If KeyAscii = 8 Then Exit Function
            If IsNumeric(SourVal & Chr(KeyAscii)) Then
               
            Else
               KeyAscii = 0
            End If
    End Function
      

  2.   

    Public Function sffunLimitNumber(ByVal IntVal As Integer) As Integer
    '-------------------1-------------------
    '目    的:只允许在文本框内输入数字、退格、删除及回车键
    '输    入:ByVal IntVal As Integer,任意的键值
    '被传递值:无
    '返 回 值:过滤后的键值
    '输    出:无
    '注    解:
    '用    法:在文本框的KeyPress事件中输入KeyAscii = sffunLimitNumber(KeyAscii)即可
    '修 订 版:
    '-------------------1-------------------
    If (IntVal <> vbKeyDelete) _
    And (IntVal <> vbKeyBack) _
    And (IntVal <> 13) _
    And (IntVal < 48 Or IntVal > 57) Then
        IntVal = 0
    End If
    sffunLimitNumber = IntValEnd Function
      

  3.   

    请解释这段函数,我在keydown事件中加了这段函数,说缺少end sub(我已经加了)
      

  4.   

    就是当输入不是数字、退格等时候Key的Ascii为0
      

  5.   

    谢谢,谢谢sffunLimitNumber  =  IntVal 这句是什么意思,可以再解释具体一点吗?
      

  6.   

    sffunLimitNumber是你傳回的數值
    IntVal是你得到的integer寫成一個模塊了,實際上完全沒有必要
    在keydown,keyascill事件中判斷就可以了
      

  7.   

    在text1的keypress事件里输入以下代码:
     
       select case keyascii
              case 48,49,50,51,52,53,54,55,56,57
                    eixt sub
              case case 8
                    exit sub
        end select
        keyascii = 0