Dim x As VB.Control
For Each x In Me.Controls
if x.Container.name="Frame" then
If VBA.VarType(VBA.CallByName(Me, x.Name, VbGet)) = vbObject Then '控件数组
Debug.Print x.text & ".Item(" & x.Index & ")"
Else
Debug.Print x.text
End If
end if
Next x
For Each x In Me.Controls
if x.Container.name="Frame" then
If VBA.VarType(VBA.CallByName(Me, x.Name, VbGet)) = vbObject Then '控件数组
Debug.Print x.text & ".Item(" & x.Index & ")"
Else
Debug.Print x.text
End If
end if
Next x
Dim aa As VB.Control
For Each aa In Me.Controls
If aa.Container Is Frame1 Then
If TypeName(aa) = "TextBox" Then Debug.Print aa.Text
End If
Next
End Sub我的也可以。原理跟阿甘的一样
为什么在我的机器上说ERROR:对象不支持这个属性或方法???fuxc(Michael) 也报告同样的错误!!
Dim aa As VB.Control
On Error Resume Next
For Each aa In Me.Controls
If aa.Container Is Frame1 Then
If TypeName(aa) = "TextBox" Then Debug.Print aa.Text
End If
Next
End Sub
Dim x As VB.Control
On Error Resume Next
For Each x In Me.Controls
If x.Container.Name = "Frame1" Then
If VBA.VarType(VBA.CallByName(Me, x.Name, VbGet)) = vbObject Then
Debug.Print x.Text & ".Item(" & x.Index & ")"
Else
Debug.Print x.Text
End If
End If
Next x
End Sub加上忽略错误不就全部Ok啊?
hehe