注册 登录
编程论坛 VB6论坛

如何判断 text 文本里只能是正整数?否则的话跳出提示?

kunsong 发布于 2014-05-11 15:09, 388 次点击
当点击“确定”按钮时,判断输入到text文本框里的字符是不是正整数,且在要求范围内
只有本站会员才能查看附件,请 登录
3 回复
#2
xzlxzlxzl2014-05-11 20:25
dim i as double,j as double
i=val(text1)
j=val(text2)
if not(i>=500 and i<=1390 and i=int(i)) then msgbox "转速设置不合格"
if not(j>=0 and j<=600000 and j=int(j)) then msgbox "采集点数不合格"
#3
fang5207312014-05-14 08:43
以下是引用xzlxzlxzl在2014-5-11 20:25:36的发言:

dim i as double,j as double
i=val(text1)
j=val(text2)
if not(i>=500 and i<=1390 and i=int(i)) then msgbox "转速设置不合格"
if not(j>=0 and j<=600000 and j=int(j)) then msgbox "采集点数不合格"


如果text1输入字符串  用val转换 是不是会报错
#4
xzlxzlxzl2014-05-14 18:41
回复 3 楼 fang520731
是吗?你应该试下嘛。
其实,不用val才会报错的,用val转换,如果碰到非数字的字符就以0返回。
1