【发布时间】:2015-01-28 23:02:46
【问题描述】:
我有一个 ComponentOne 输入面板“inputPanel”从数据库中提取记录,
我想验证除名称文本框“txtNAME”之外的所有框,
“检查”是一个测试没有特殊字符的函数
For Each ctrl As Control In inputPanel.Controls
If ctrl.Name <> "txtNAME" Then
check= ctrl.Text
If NumText(check) = False Then
MessageBox.Show("You can only Enter Numbers and Text for this field", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error)
ctrl.Focus()
Exit Sub
End If
End If
Next
它仍在检查 txtName 是否有特殊字符
有什么帮助吗?
【问题讨论】:
-
名称是否完全正确?您的比较是类型敏感的。
-
名称正确,忽略
-
就其价值而言,像这样比较名称并不是很好。我会推荐
If ctrl IsNot txtNAME Then。 -
您在此面板中是否有其他类型的控件? (例如标签)
-
是的标签和文本框,它只是忽略了 isNot too。