If IsCtrExist("UserForm1", "ComboBox1") Then MsgBox "存在" Else MsgBox "不存在"
Public Function IsCtrExist(ByVal nameUF As String, ByVal nameC As String) As Boolean
Dim 存在1 As Boolean
Dim 存在2 As Boolean
Dim N%, i%
For i = 1 To UserForms.Count
If UserForms.Item(i - 1).name = nameUF Then 存在1 = True: N = i - 1
Next i
If Not 存在1 Then GoTo 101
For Each c In UserForms.Item(N).Controls
If c.name = nameC Then 存在2 = True
Next
101:
If 存在2 Then IsCtrExist = True Else IsCtrExist = False
End Function作者: 准提部林 時間: 2018-11-11 23:04