如果对文本框内容进行自动把不要的信息删除,比如:text1中的要求是:1,2,3,4,5这样,要在100以下
当从外部加载123.txt时,如果进行自动过滤?123.txt内容可能是:1,2, abc,10000000000,54545
如何把那个abc,10000000000,54545这样的自动过滤,或者是加载中提示错误!另一个问题:
在text1可以手工输入数字1,2,3,4,5这样,也在100以下
如果可以让它在输入大于100时弹出错误提示,而继续输入数据!!各位大侠,请帮帮小弟!!!谢谢了!!

解决方案 »

  1.   

    第一个问题,没看明白你的意思.
    第二个看代码:
    Private Sub Text1_KeyPress(KeyAscii As Integer)InputNumeric KeyAscii, Text1 '文本框只能输入数字
    If Int(Text1.Text) > 100 Then  ' 判断数据大小
    MsgBox "数值不能大于100"
    End If
    End Sub
    '文本框只能输入数字, 来自csdn
    Public Sub InputNumeric(KeyAscii As Integer, txtItem As TextBox)
        Select Case KeyAscii
            Case Asc("-") '允许负数
                If txtItem.SelStart = 0 Then
                  If Left(txtItem.Text, 1) = "-" Then
                      KeyAscii = 0
                      Beep
                  End If
                Else
                  KeyAscii = 0
                  Beep
                End If
            Case 8
                  '无变化,退格键不屏蔽
            Case Asc(" ") '32
                If txtItem.SelLength = 0 Then
                    KeyAscii = 0
                End If
            Case Asc(".") '46 '允许小数点
                If InStr(txtItem.Text, ".") Then
                    KeyAscii = 0
                End If
            Case Is < Asc(0) '48
                  KeyAscii = 0
            Case Is > Asc(9) '57
                  KeyAscii = 0
        End Select
    End Sub
      

  2.   

    问题1:
    1。把文件读到一个string类型变量StrA中
    2。准备一个string动态数组Arr1,然后Arr1=split(strA,",")
    3。准备一个long型的动态数组Arr2
     for i=0 to ubound(arr1)
      if IsNumeric(arr1(i)) =true and clng(arr1(i))<100 then 
         ReDim Preserve Arr2(UBound (DynArray) + 1)
         Arr2(ubound(Arr2))=clng(arr1(i))
      end if
     next iok了
      

  3.   

    不好意思,上面代码有错!Private Sub Text1_KeyPress(KeyAscii As Integer)InputNumeric KeyAscii, Text1 '文本框只能输入数字End Sub
    '文本框只能输入数字, 来自csdn
    Public Sub InputNumeric(KeyAscii As Integer, txtItem As TextBox)
        Select Case KeyAscii
            Case Asc("-") '允许负数
                If txtItem.SelStart = 0 Then
                  If Left(txtItem.Text, 1) = "-" Then
                      KeyAscii = 0
                      Beep
                  End If
                Else
                  KeyAscii = 0
                  Beep
                End If
            Case 8
                  '无变化,退格键不屏蔽
            Case Asc(" ") '32
                If txtItem.SelLength = 0 Then
                    KeyAscii = 0
                End If
            Case Asc(".") '46 '允许小数点
                If InStr(txtItem.Text, ".") Then
                    KeyAscii = 0
                End If
            Case Is < Asc(0) '48
                  KeyAscii = 0
            Case Is > Asc(9) '57
                  KeyAscii = 0
        End Select
    End SubPrivate Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
    If Len(Text1.Text) > 0 Then
    If Int(Text1.Text) >= 100 Then  ' 判断数据大小
    MsgBox "数值不能大于100"
    End If
    End If
    End Sub
    你试试
      

  4.   

    浪费了,如果是小于100,而且是整数,就把arr2定义为byte型的,然后用Cbyte()类型转化
      

  5.   

    那怎么屏蔽掉text的右键菜单呢?以及ctrl+v