如题!

解决方案 »

  1.   

    Private Sub Command1_Click()
    If IsNumeric(Text1.Text) = False Then
        MsgBox "±§Ç¸£¬ÇëÊäÈë´¿Êý×Ö"
    End If
    End Sub
      

  2.   


    Option ExplicitPrivate Sub Form_Load()
        Text1 = ""
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = Asc(".") Then
            Text1 = Text1
        Else
            KeyAscii = 0
        End If
    End Sub
      

  3.   

    Option Explicit
    Private Sub Form_Load()
        Text1 = ""
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = Asc(".") Then
            Text1 = Text1
        Else
            MsgBox "抱歉,请输入纯数字"
            KeyAscii = 0
        End If
    End Sub
      

  4.   

    楼上的最好增加一个backspace和delete,这样就ok了
      

  5.   

    无小数:Private Sub Form_Load()
        Text1 = ""
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") And Len(Text1) < 5 Or KeyAscii = vbKeyBack Then
            Text1 = Text1
        Else
            MsgBox "抱歉,请输入纯数字或输入数字超过5位"
            KeyAscii = 0
        End If
    End Sub