奇怪,俺输入0时,居然被认为不是数值型数据.现求助!
If IsNumeric(Me.Text5) = False Then
Text5.SetFocus
Text5.SelStart = 0
Text5.SelLength = Len(Text5.Text)
MsgBox "请在数量中输入数值型数据!", 64, "提示"
Exit Sub
End If

解决方案 »

  1.   

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

  2.   

    没啥问题:Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
    If IsNumeric(Me.Text5) = False Then
    Text5.SetFocus
    Text5.SelStart = 0
    Text5.SelLength = Len(Text5.Text)
    MsgBox "请在数量中输入数值型数据!", 64, "提示"
    Exit Sub
    Else
    MsgBox "输入的是数值型数据!", 64, "提示"
    End If
    End If
    End Sub
      

  3.   


    if step=1 thenend if
      

  4.   

    这段代码看起来是没啥问题
    如果你是放到keydown事件中
    那么当你第一次输入时,是会提示的,
    因为第一次输入时,文本框为空,这样isnumeric就不是true了