on error resume next for i = 0 to sstab.tabs -1 sstab.tab = i for each ctl in sstab.Container if ctl.left > 0 then msgbox "control " & ctl.name & " is on tab" & sstab.tabcaption(i) end if next next
' 多拉一个 Command2 放在 Form1上面 (不是放在 SStab 上) ' 发现怪问题 ' 按下 Command2 --> 执行 Sub Command2_Click() 时 ' MsgBox 却出现 "control Command2 is on tab 0" ' 每当 SSTab.Tab = i 改变后, 就会出现 Command2Private Sub Command2_Click() On Error Resume Next For i = 0 To SSTab.Tabs - 1 SSTab.Tab = i For Each ctl In SSTab.Container If ctl.Left > 0 Then MsgBox "control " & ctl.Name & " is on tab" & SSTab.TabCaption(i) End If Next Next End Sub
加ctl.Container.name If ctl.Left > 0 and ctl.Container.name = "SSTab" then
On Error Resume Next Dim ctl As Control For Each ctl In Me.Controls If ctl.Container Is SSTab Then If err.Number = 0 Then MsgBox ctl.Name & " is on tab" & SSTab.TabCaption(SSTab.Tab) Else err.Clear End If End If Next
for i = 0 to sstab.tabs -1
sstab.tab = i
for each ctl in sstab.Container
if ctl.left > 0 then
msgbox "control " & ctl.name & " is on tab" & sstab.tabcaption(i)
end if
next
next
' 发现怪问题
' 按下 Command2 --> 执行 Sub Command2_Click() 时
' MsgBox 却出现 "control Command2 is on tab 0"
' 每当 SSTab.Tab = i 改变后, 就会出现 Command2Private Sub Command2_Click()
On Error Resume Next
For i = 0 To SSTab.Tabs - 1
SSTab.Tab = i
For Each ctl In SSTab.Container
If ctl.Left > 0 Then
MsgBox "control " & ctl.Name & " is on tab" & SSTab.TabCaption(i)
End If
Next
Next
End Sub
If ctl.Left > 0 and ctl.Container.name = "SSTab" then
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Container Is SSTab Then
If err.Number = 0 Then
MsgBox ctl.Name & " is on tab" & SSTab.TabCaption(SSTab.Tab)
Else
err.Clear
End If
End If
Next
很多控件是没有container属性的,Inet,timer,CommonDialog,Winsock等