我知道是在 text的KeyPress事件中 设置代码 
可是到底 如何写?谁能帮我写一下,谢谢你了!!!!!!!!!!!!!!

解决方案 »

  1.   

    If KeyAscii > Asc(9) Or KeyAscii < Asc(0) Then
        KeyAscii = 0
        End If
      

  2.   

    在delphi中我是这样做的,你可修改if not key in ['0'..'9','.','#8] then key:=#0;
      

  3.   

    Private Sub Text1_Change()
       If IsNumeric(Text1.Text) = False Then
          MsgBox "请输入数字"
          If Text1.Text <> "" Then
             Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
          End If
       End If
    End Sub
      

  4.   

    If KeyAscii > Asc(9) Or KeyAscii < Asc(0) Then
        Msgbox "这个文本框只能输入数字!!!",vbinformation,"提示"
        Text1.setfocus
    End If
      

  5.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If Chr(KeyAscii) Like "[0-9]" Or KeyAscii = vbKeyBack Then
        Else
            KeyAscii = 0
        End If
    End Sub
      

  6.   

    If KeyAscii > Asc(9) Or KeyAscii < Asc(0) or keyascii<>asc(,) or keyascii<>asc(.) or keyascii<>8 Then
        KeyAscii = 0
        End If
      

  7.   

    系统函数对ASCII表和映射表都分了区间,可通过枚举段列来在系统级得到处理,效果更好并且同时能任意定义这个区间。