首页 > 开发 > 综合 > 正文

限制文本框的输入(只输入数字)

2024-07-21 02:25:36
字体:
来源:转载
供稿:网友
文本框防止非法字符输入:

只输入整数:
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

case else
keyascii = 0

end select
end sub



发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表