请问各位高手.
当用户在文本框里输入小数的时候,
不充许输入两个小数点.
这该怎么办

解决方案 »

  1.   

    Option ExplicitPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        Dim s As String
        s = Text1.Text
        If KeyAscii = 46 Then
            If InStr(1, s, ".") >= 1 Then
                MsgBox "只能有一个小数点"
                KeyAscii = 0
            End If
        End If
    End Sub
      

  2.   

    Text1_Validate更能让光标锁在text1,除非小数点符合要求,否则永远留在text1
      

  3.   

    还有一个方法,用maskedbox控件
      

  4.   

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