通过我的复选框,For Each Next循环有什么顺序 [英] What order does a For Each Next loop through my checkboxes

查看:201
本文介绍了通过我的复选框,For Each Next循环有什么顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大约20个复选框放在一个矩形。对于每个循环,我如何知道我的代码循环使用什么顺序?



我已经确认它不是CheckBox1,CheckBox2,CheckBox3等的顺序。

解决方案

对于在工作表上布局的ActiveX复选框控件,< right-click> ,Order命令设置它们在For ...每个循环中检索的顺序。请注意,命令似乎是向后的。




  1. 带到前面 将形状对象放在For Each队列的尾端。

  2. 发送到后面 将把Shape对象放在For Each队列的前面。

  3. 转发 将把形状对象重新排列在队列中的一个位置。

  4. S结束向后 将向前推动形状对象在队列中的一个位置。

Shape.ZOrder方法

 使用工作表(Sheet1)
.Shapes(CheckBox2)。ZOrder msoBringForward'< ~~发回一个地方队列
.Shapes(CheckBox2)。ZOrder msoSendToBack'< ~~在队列开头的位置
结束

使用 Shape .ZOrderPosition属性以确定当前位置。


I have about 20 Check Boxes laid out in a rectangle. How do I know what order my code loops through them with a For Each loop?

I've already confirmed it is not in the order of CheckBox1, CheckBox2, CheckBox3 etc.

解决方案

For ActiveX checkbox controls laid out on the worksheet, the <right-click>, Order command sets the order they are retrieved in a For ... Each loop. The caveat is that the commands seem to be backwards.

        

  1. Bring to Front will place the shape object at the tail end of the For Each queue.
  2. Send to Back will bring the shape object to the front of the For Each queue.
  3. Bring Forward will shuffle the shape object back one place in the queue.
  4. Send Backward will push the shape object forward one place in the queue.

The VBA for this is in the Shape.ZOrder method.

With Worksheets("Sheet1")
    .Shapes("CheckBox2").ZOrder msoBringForward  '<~~ send back one place in the queue
    .Shapes("CheckBox2").ZOrder msoSendToBack  '<~~ place at the beginning of the queue
End With

Use the Shape.ZOrderPosition property to determine the current position.

这篇关于通过我的复选框,For Each Next循环有什么顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆