首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

在线问个有关问题

2012-01-26 
在线问个问题代码如下:问题在“有问题”那段代码,问题就是,我输入数字时还是会显示 Pleaseinputinteger! I

在线问个问题
代码如下:
问题在“有问题”那段代码,问题就是,我输入数字时还是会显示 "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


[解决办法]
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48) Or (KeyAscii > 57) Then
Text3 = "Please input integer! " '有问题
End If
End Sub

热点排行