如何读取标签的一部分并在For循环中使用它。 [英] How to read part of a label and use it within a For Loop.

查看:94
本文介绍了如何读取标签的一部分并在For循环中使用它。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有18个标有YB1到YB18的组合框。这些框可以在输入表单上设置为是或否。

我希望能够首先读取标签末尾的数字。然后使用该数字作为For循环的第一部分。

然后我希望能够使用for循环将所有后续组合框的值设置为是

一旦组合框被用户设置为是。

即如果用户将YB6设置为是,则代码将组合框YB7至YB 18设置为是。

我不知道的是首先如何读取盒子的数量。其次,使用For循环变量创建组合框标签。

I have 18 combo boxes labelled YB1 to YB18. These boxes can either be set to "Yes" or "No" on the input form.
I want to be able to firstly read the number at the end of the label. Then use that number as the first part of a For Loop.
Then I want to be able to use a for loop to set all subsequent combo boxes' value to Yes
once a combo box has been set by the user to Yes.
ie If the user sets YB6 to Yes then the code sets Combo boxes YB7 to YB 18 to Yes.
What I do not know is firstly how to read the number of the box. Secondly to create the combobox label using a For Loop variable.

推荐答案

您可以在循环中使用Controls.Find()。它需要控件的字符串名称。



例如,如果我是你的循环变量:

You can use Controls.Find() in a loop. It takes a string name for the control.

For example, if i is your loop variable:
ComboBox cbx = Controls.Find("YB" + i, true)
IF cbx IS NOT NOTHING THEN
 ...
END


这篇关于如何读取标签的一部分并在For循环中使用它。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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