我创建了一个函数来检查我的表单中是否有控件类型,但它没有用,我不知道问题出在哪里。
这是我写的代码:
Private Function testIfControlExists(ByVal _Control As Control)
For Each c As Control In Me.Controls
If TypeOf c Is _Control Then
Return True
End If
Next
Return False
End Function
这是我收到的错误消息:
错误1未定义类型'_Control'。
答案 0 :(得分:2)
如果要检查表单是否具有控件类型,则可以执行以下操作:
Public Function testIfControlExists(ByVal _Control As Control) As Boolean
For Each c As Control In Me.Controls
If c.GetType Is _Control.GetType Then
Return True
End If
Next
Return False
End Function
答案 1 :(得分:0)
更改
If TypeOf c Is _Control Then
要
If TypeOf c Is Control Then
祝你好运
答案 2 :(得分:0)
请参阅文档here
您不能以您尝试的方式使用它。您可以将其用于数据类型名称,例如Integer
,String
等。