好象有个函数什么的,或者直接在textbox里面有哪个属性就可以设置。

解决方案 »

  1.   

    请看例程:
    Private Sub txtHeight_Validate(Cancel As Boolean)
        With Me.txtHeight
            If Not IsNumeric(.Text) Then
                MsgBox "不是一个合法的数字,请重新输入!", vbInformation
                Cancel = True
                Call txtHeight_GotFocus
            ElseIf CSng(.Text) < Module1.Hmin Or CSng(.Text) > Module1.Hmax Then
                MsgBox "水位必须界于 " & CStr(Module1.Hmin) & " ~ " & CStr(Module1.Hmax) & " 之间,请重新输入!", vbInformation
                Cancel = True
                Call txtHeight_GotFocus
            End If
        End With
    End Sub
      

  2.   

    If IsNumeric(TextBox1.Text) Then
       MsgBox "Is number"
    End If
      

  3.   

    if trim(text1.text)<>"" then
        if not isnumeric(text1.text) then
            msgbox "请输入数值型数据!",48,"提示"
            text1.setfocus
        end if
    end if