您的位置:程序门 -> vb -> 基础类



在线问个问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


在线问个问题[已结贴,结贴人:popkiki648]
发表于:2007-06-14 09:10:32 楼主
代码如下:
问题在“有问题”那段代码,问题就是,我输入数字时还是会显示 "please   input   integer! "  


if   (text1   =   " ")   then   '如果未输入值,提示错误
      text3   =   "please   input   number! "
      text1.setfocus
else
      sum   =   0:   temp   =   text1
      for   a   =   1   to   temp
              sum   =   sum   +   a
      next   a
end   if
text2   =   sum
end   sub


private   sub   command2_click()
text1   =   " ":   text3   =   " "   '重新输入数据
text1.setfocus
end   sub

private   sub   command3_click()
text1   =   " ":   text2   =   " ":   text3   =   " "
end   sub

private   sub   command4_click()
unload   me
end   sub
private   sub   text1_keypress(keyascii   as   integer)
if   (text1   <   "48 ")   or   (text1   >   "57 ")   then
text3   =   "please   input   integer! "       '有问题
end   if
end   sub

private   sub   text2_keypress(keyascii   as   integer)
text1.setfocus
end   sub
发表于:2007-06-14 09:22:221楼 得分:10
private   sub   text1_keypress(keyascii   as   integer)
if   (keyascii   <   48)   or   (keyascii   >   57)   then
text3   =   "please   input   integer! "       '有问题
end   if
end   sub
发表于:2007-06-14 09:26:022楼 得分:0
it   is   a   mess   code!
text1是字符串,temp也是,不是integer   !!!!
"57 "   and   "48 "   是字符串!!!
(text1   <   "48 ")   or   (text1   >   "57 ")   '????

sum   =   0:   temp   =   text1
for   a   =   1   to   temp     'temp是字符串
sum   =   sum   +   a
next   a

come   on,回家读书去吧,不要浪费大家时间!


快速检索

最新资讯
热门点击