连For Each都不会用了..求助啊!

keekeep 2004-08-24 05:07:26
我的窗体上有四个PictureBox 点一个按纽,用For Each遍历所有的picturebox,让Name="panel"的.Visible属性=True,其它的.visible属性=False.

请帮忙.在线等....解决就结贴!
...全文
197 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2004-08-24
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim p As Control
For Each p In Me.Controls
If TypeOf p Is PictureBox Then p.Visible = False
Next
Me.Controls("panel").Visible = True
End Sub
laviewpbt 2004-08-24
  • 打赏
  • 举报
回复
注意啊,panel的大小写一定要对啊,如果把panel该为Panel那就不对了。
ryuginka 2004-08-24
  • 打赏
  • 举报
回复
dim cc as control

for each cc in me.controls
if typeof cc is PictureBox then
if cc.name = "panel" then
cc.Visible = True
else
cc.Visible = False
End if
end if
next
bladeinside 2004-08-24
  • 打赏
  • 举报
回复
Dim x As Control
Dim y As frmTest
For Each x In y
If TypeOf x Is PictureBox And x.Name = "" Then
x.Visible = True
ElseIf TypeOf x Is PictureBox And x.Name <> "" Then
.Visible = False
End If
Next x
你试试
of123 2004-08-24
  • 打赏
  • 举报
回复
if cc.name = "panel" then
of123 2004-08-24
  • 打赏
  • 举报
回复
dim cc as control

for each cc in me.controls
if typeof cc is PictureBox then
if cc.name = panel then
cc.Visible = True
else
cc.Visible = False
End if
end if
next
apple1980 2004-08-24
  • 打赏
  • 举报
回复
Dim f1 As PictureBox
For Each f1 In Form1
rr = f1.Name
If rr = "Picture2" Then
Picture2.Visible = False
Exit Sub
End If
Next

7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧