用函数进行判断
对于1,可以用keypress
对于2,只有自己做了

解决方案 »

  1.   

    1.在keypress事件中判断keyascii的值,如果不是你想要的就作处理.例如:
      你想屏蔽回车键,就在keyascii事件中写如下代码:
      if keyascii=13 then keyascii=02.用format函数,对textbox中的值进行format后再赋还给textbox
      

  2.   

    public blDot as boolerPrivate Sub text1_KeyPress(keyascii As Integer)
      
     if keyascii=8 then exit sub if keyascii=Asc(".") and blDot then 
        keyascii=0
        exit sub
     endif
     if keyasciiAsc(".") and !blDot then
        blDot=True
        exit sub
     endifIf (keyascii < Asc("0") Or keyascii > Asc("9")) then
      
        Asckeyascii = 0
        exit subEnd IfEnd Sub
    Private Sub text1_Change( )
       if InStr(text1.Text,".") then
          blDot=True
       else
          blDot=Flase
       endif
      if len(text1.text)-instr(text1.text,".")>2 then
         text1.text=left(text1.text,len(text1.text)-1)
      endif
    End Sub