作者在 2007-05-06 18:11:00 发布以下内容
'约束用户输入的信息:只能为正整数(放在Text_Change中)
Public Sub checkinput(obj As TextBox)
Dim i As Integer
If Left(obj.Text, 1) = "0" Then
obj.Text = ""
MsgBox "仅能输入正整数!", 0, "注意"
Exit Sub
End If
For i = 1 To Len(obj.Text)
If Asc(Mid(obj.Text, i)) > 57 Or Asc(Mid(obj.Text, i)) < 48 Then
obj.Text = ""
MsgBox "仅能输入正整数!", 0, "注意"
Exit Sub
End If
Next
End Sub
Public Sub checkinput(obj As TextBox)
Dim i As Integer
If Left(obj.Text, 1) = "0" Then
obj.Text = ""
MsgBox "仅能输入正整数!", 0, "注意"
Exit Sub
End If
For i = 1 To Len(obj.Text)
If Asc(Mid(obj.Text, i)) > 57 Or Asc(Mid(obj.Text, i)) < 48 Then
obj.Text = ""
MsgBox "仅能输入正整数!", 0, "注意"
Exit Sub
End If
Next
End Sub