只输入整数: private sub text1_keypress(keyascii as integer) select case keyascii case asc("0") to asc("9"), vbkeyback 'nop case else keyascii = 0 end select end sub
只输入小数:
private sub text1_keypress(keyascii as integer) select case keyascii case asc("0") to asc("9"), vbkeyback 'nop
case asc(".")'允许一个小数点 if instr(1, text1.text, ".") > 0 then keyascii = 0