找不到方法或数据成员 [英] Method or Data Member not Found
问题描述
大家好,
如果有空白,我正在尝试验证表单中的所有文本框。但我得到方法或数据成员未找到错误
这是代码:
Dim ctl As Control
For each ctl In Me。 Controls '
如果TypeName(ctl)=TextBox那么
如果ctl.Value =那么
msg = MsgBox(所有字段必需,vbExclamation + vbOKOnly + vbApplicationModal,警告)
退出Sub
结束如果
结束如果
下一步ctl
< Me.Controls>在我的第一行突出显示错误。
不确定我是否错过了在工具>下添加类似ActiveX控件的引用参考资料。
提前谢谢。
Hi Everyone,
I'm trying to validate all text boxes in my form if there are blanks. but i'm getting "Method or Data Member not Found" Error
Here is the code:
Dim ctl As Control
For Each ctl In Me.Controls'
If TypeName(ctl) = "TextBox" Then
If ctl.Value = "" Then
msg = MsgBox("All Fields Required", vbExclamation + vbOKOnly + vbApplicationModal, "Warning")
Exit Sub
End If
End If
Next ctl
The <Me.Controls> on my first line gets highlighted with error.
not not sure if i had missed to add a reference like ActiveX Control under Tools > References.
thanks in advance.
推荐答案
我想你想迭代一下控件表。
所以,你的回答是这里 [ ^ ]。
I think you want to iterate through the controls on a Sheet.
So, your your answer is here[^].
您的代码看起来没问题。
请参考以下链接:
[ ^ ]
如何在Excel中的工作表上使用表单控件 [ ^ ]
Your code looks OK.
Please, refer these links:
Overview of forms, Form controls, and ActiveX controls on a worksheet[^]
How to use the forms controls on a worksheet in Excel[^]
这篇关于找不到方法或数据成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!