我需要限制用户窗体中的文本框以接受50000到59999之间的值;并接受空白条目。
如果不满足这些条件,则应再次显示用户表单。
答案 0 :(得分:0)
这应该在用户单击尝试提交的按钮中。在执行任何操作之前运行此命令-如果满足您的条件,代码将停止并返回表格。
我猜您也希望引起对非数字条目的关注。
If Textbox.Value < 50000 or TextBox.Value > 59999 or Not IsNumeric(TextBox) Then
Textbox.SetFocus
MsgBox "Invalid Entry"
Exit Sub
End If
我想到允许空白条目的第一件事就是插入一个空格以显示空白条目的外观,但是我确信有更好的方法来做到这一点。
If Len(TextBox.Value) = 0 Then TextBox.Value = Chr(32)
答案 1 :(得分:0)
Private Sub TextBox3_AfterUpdate()
If TextBox3.Value < 50000 Or TextBox3.Value > 59999 Or TextBox3.Value = "" Then
MsgBox ("worng entry")
TextBox3.Value = ""
Exit Sub
End If
End Sub