读书人

在线问个有关问题

发布时间: 2012-01-26 19:40:46 作者: rapoo

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

读书人网 >VB

热点推荐