求解一道编程题 简单!~~~我不会

来源:百度知道 编辑:UC知道 时间:2024/09/23 03:12:25
在窗体上设置一个文本框控件,用于接受用户输入的数据。编写程序要求文本框只能接受15-30之间的正整数
1.不能输入空值,字符,不能超过13-30
2.可以通过isnumeric函数来判断输入的是否是数字

这是在access中的一个题。。。。。。。。。。帮忙啊!~~~~~
天啊。。。。。。。。。。。。。。。还是不行又说什么空间没焦点不能引用

添加一个commandbutton来验证,代码如下(在VB6.0下测试通过)

其中 MsgBox "输入通过验证!", vbInformation 可以修改成你需要的代码

Private Sub Command1_Click()
If Text1.Text = "" Then MsgBox "不允许输入空字符串!", vbInformation
If IsNumeric(Text1.Text) Then
If Len(Text1.Text) >= 13 And Len(Text1.Text) <= 25 Then
MsgBox "输入通过验证!", vbInformation
Else
MsgBox "非法输入!", vbInformation
End If
Else
MsgBox "非法输入!", vbInformation
End If
End Sub

Const xStr As String = "0123456789"

Private Sub Command1_Click()
If IsNumeric(Text1.Text) Then
If Val(Text1.Text) >= 15 And Val(Text1.Text) <= 30 Then
MsgBox "输入正确!", vbInformation
Else
MsgBox "不在范围!", vbInformation
End If
Else
MsgBox "不在范围!", vbInformation
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)